Class List Method List File List

# Module: WpItem::Versionable

Included in:
  WpItem
Defined in:
  lib/common/models/wp_item/versionable.rb

## Instance Method Summary (collapse)

- - (String) to_s
- - (String) version

  Get the version from the readme.txt.

## Instance Method Details

### - (`String`) to_s

Returns:

- (`String`)

    23
    24
    25
    26
    # File 'lib/common/models/wp_item/versionable.rb', line 23

    def to_s
      item_version = self.version
      "#@name#{' v' + item_version.strip if item_version}"
    end

### - (`String`) version

Get the version from the readme.txt

Returns:

- (`String`) —

  The version number

    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    # File 'lib/common/models/wp_item/versionable.rb', line 11

    def version
      unless @version
        # This check is needed because readme_url can return nil
        if has_readme?
          response = Browser.get(readme_url)
          @version = response.body[%r{stable tag: #{WpVersion.version_pattern}}i, 1]
        end
      end
      @version
    end