Class: Orchid::Version
- Inherits:
-
Object
- Object
- Orchid::Version
- Defined in:
- lib/orchid.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
Returns the value of attribute major.
-
#micro ⇒ Object
Returns the value of attribute micro.
-
#minor ⇒ Object
Returns the value of attribute minor.
Instance Method Summary collapse
-
#initialize(value = nil) ⇒ Version
constructor
A new instance of Version.
- #to_a ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value = nil) ⇒ Version
Returns a new instance of Version.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/orchid.rb', line 38 def initialize(value = nil) if value.class == String value = value.split '.' elsif value.class == Hash value = [value[:major], value[:minor], value[:micro]] elsif value.nil? value = [nil, 0, 0] end @major = value.first ? value.first.to_i : nil @minor = value[1] ? value[1].to_i : 0 @micro = value.last ? value.last.to_i : 0 end |
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major.
36 37 38 |
# File 'lib/orchid.rb', line 36 def major @major end |
#micro ⇒ Object
Returns the value of attribute micro.
36 37 38 |
# File 'lib/orchid.rb', line 36 def micro @micro end |
#minor ⇒ Object
Returns the value of attribute minor.
36 37 38 |
# File 'lib/orchid.rb', line 36 def minor @minor end |
Instance Method Details
#to_a ⇒ Object
60 61 62 |
# File 'lib/orchid.rb', line 60 def to_a return [@major, @minor, @micro] end |
#to_h ⇒ Object
56 57 58 |
# File 'lib/orchid.rb', line 56 def to_h return {:major => @major, :minor => @minor, :micro => @micro} end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/orchid.rb', line 52 def to_s return "#{@major}.#{@minor}.#{@micro}" end |