Class: Jekyll::GeneratorSingleSource::Product::Release
- Inherits:
-
Object
- Object
- Jekyll::GeneratorSingleSource::Product::Release
- Defined in:
- lib/jekyll/generator-single-source/product/release.rb
Instance Attribute Summary collapse
-
#release_hash ⇒ Object
readonly
Returns the value of attribute release_hash.
Instance Method Summary collapse
- #default_version ⇒ Object
- #edition ⇒ Object
-
#initialize(release_hash) ⇒ Release
constructor
A new instance of Release.
- #label ⇒ Object
- #latest? ⇒ Boolean
- #lts ⇒ Object
- #tag ⇒ Object
- #to_h ⇒ Object
- #to_liquid ⇒ Object
- #to_semver ⇒ Object
- #to_str ⇒ Object (also: #to_s)
- #value ⇒ Object
- #versions ⇒ Object
Constructor Details
#initialize(release_hash) ⇒ Release
Returns a new instance of Release.
9 10 11 12 13 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 9 def initialize(release_hash) @release_hash = release_hash validate! end |
Instance Attribute Details
#release_hash ⇒ Object (readonly)
Returns the value of attribute release_hash.
7 8 9 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 7 def release_hash @release_hash end |
Instance Method Details
#default_version ⇒ Object
49 50 51 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 49 def default_version @default_version ||= versions['default'] end |
#edition ⇒ Object
15 16 17 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 15 def edition @edition ||= @release_hash.fetch('edition') end |
#label ⇒ Object
27 28 29 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 27 def label @label ||= @release_hash['label'] end |
#latest? ⇒ Boolean
23 24 25 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 23 def latest? @release_hash['latest'] end |
#lts ⇒ Object
31 32 33 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 31 def lts @lts ||= @release_hash['lts'] end |
#tag ⇒ Object
45 46 47 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 45 def tag @tag ||= value.split('.')[0..1].join('.') end |
#to_h ⇒ Object
70 71 72 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 70 def to_h @release_hash end |
#to_liquid ⇒ Object
66 67 68 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 66 def to_liquid Liquid::Drops::Release.new(self) end |
#to_semver ⇒ Object
62 63 64 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 62 def to_semver value.gsub('-x', '.x').gsub(/\.x/, '.0') end |
#to_str ⇒ Object Also known as: to_s
53 54 55 56 57 58 59 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 53 def to_str if @release_hash.key?('label') label else value end end |
#value ⇒ Object
19 20 21 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 19 def value @value ||= @release_hash['release'] end |
#versions ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/jekyll/generator-single-source/product/release.rb', line 35 def versions @versions ||= begin if @release_hash.has_key?('version') { 'default' => @release_hash['version'] } else versions_without_suffix end end end |