Class: Pair
- Inherits:
-
Object
- Object
- Pair
- Defined in:
- lib/static_ruby.rb
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#second ⇒ Object
readonly
Returns the value of attribute second.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #!=(o) ⇒ Object
- #==(o) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(first, second) ⇒ Pair
constructor
A new instance of Pair.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(first, second) ⇒ Pair
Returns a new instance of Pair.
4 5 6 7 8 |
# File 'lib/static_ruby.rb', line 4 def initialize(first, second) @first = first @second = second @size = 2 end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
2 3 4 |
# File 'lib/static_ruby.rb', line 2 def first @first end |
#second ⇒ Object (readonly)
Returns the value of attribute second.
2 3 4 |
# File 'lib/static_ruby.rb', line 2 def second @second end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
2 3 4 |
# File 'lib/static_ruby.rb', line 2 def size @size end |
Instance Method Details
#!=(o) ⇒ Object
22 23 24 |
# File 'lib/static_ruby.rb', line 22 def !=(o) @first != o.first || @second != o.second end |
#==(o) ⇒ Object
18 19 20 |
# File 'lib/static_ruby.rb', line 18 def ==(o) @first == o.first && @second == o.second end |
#each(&block) ⇒ Object
26 27 28 29 |
# File 'lib/static_ruby.rb', line 26 def each(&block) block.call(@first) block.call(@second) end |
#to_a ⇒ Object
10 11 12 |
# File 'lib/static_ruby.rb', line 10 def to_a [@first, @second] end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/static_ruby.rb', line 14 def to_s "Pair(#{@first} #{@second})" end |