Class: TripleCounter
- Inherits:
-
Struct
- Object
- Struct
- TripleCounter
- Defined in:
- lib/distorted/modular_technology/triple_counter.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
- #<(otra) ⇒ Object
- #<=(otra) ⇒ Object
- #==(otra) ⇒ Object
- #===(otra) ⇒ Object
- #>(otra) ⇒ Object
- #>=(otra) ⇒ Object
- #all_operator(otra, operator) ⇒ Object
-
#initialize(major = 0, minor = 0, micro = 0) ⇒ TripleCounter
constructor
A new instance of TripleCounter.
- #to_array ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(major = 0, minor = 0, micro = 0) ⇒ TripleCounter
Returns a new instance of TripleCounter.
4 5 6 7 8 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 4 def initialize(major = 0, minor = 0, micro = 0) @major = major @minor = minor @micro = micro end |
Instance Attribute Details
#major ⇒ Object
Returns the value of attribute major
1 2 3 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 1 def major @major end |
#micro ⇒ Object
Returns the value of attribute micro
1 2 3 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 1 def micro @micro end |
#minor ⇒ Object
Returns the value of attribute minor
1 2 3 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 1 def minor @minor end |
Instance Method Details
#<(otra) ⇒ Object
34 35 36 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 34 def <(otra) all_operator(otra, :<) end |
#<=(otra) ⇒ Object
26 27 28 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 26 def <=(otra) all_operator(otra, :<=) end |
#==(otra) ⇒ Object
14 15 16 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 14 def ==(otra) major == otra.major && minor == otra.minor end |
#===(otra) ⇒ Object
18 19 20 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 18 def ===(otra) all_operator(otra, :==) end |
#>(otra) ⇒ Object
30 31 32 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 30 def >(otra) all_operator(otra, :>) end |
#>=(otra) ⇒ Object
22 23 24 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 22 def >=(otra) all_operator(otra, :>=) end |
#all_operator(otra, operator) ⇒ Object
42 43 44 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 42 def all_operator(otra, operator) to_array.zip(otra.to_array).all?{|us, otra| us.send(operator, otra)} end |
#to_array ⇒ Object
38 39 40 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 38 def to_array [major, minor, micro] end |
#to_s ⇒ Object
10 11 12 |
# File 'lib/distorted/modular_technology/triple_counter.rb', line 10 def to_s [major, minor, micro].join('.'.freeze) end |