Class: Triple

Inherits:
Object
  • Object
show all
Defined in:
lib/static_ruby.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(first, second, third) ⇒ Triple

Returns a new instance of Triple.



36
37
38
39
40
41
# File 'lib/static_ruby.rb', line 36

def initialize(first, second, third)
  @first = first
  @second = second
  @third = third
  @size = 3
end

Instance Attribute Details

#firstObject (readonly)

Returns the value of attribute first.



34
35
36
# File 'lib/static_ruby.rb', line 34

def first
  @first
end

#secondObject (readonly)

Returns the value of attribute second.



34
35
36
# File 'lib/static_ruby.rb', line 34

def second
  @second
end

#sizeObject (readonly)

Returns the value of attribute size.



34
35
36
# File 'lib/static_ruby.rb', line 34

def size
  @size
end

#thirdObject (readonly)

Returns the value of attribute third.



34
35
36
# File 'lib/static_ruby.rb', line 34

def third
  @third
end

Instance Method Details

#!=(o) ⇒ Object



55
56
57
# File 'lib/static_ruby.rb', line 55

def !=(o)
  @first != o.first || @second != o.second || @third != o.third
end

#==(o) ⇒ Object



51
52
53
# File 'lib/static_ruby.rb', line 51

def ==(o)
  @first == o.first && @second == o.second && @third == o.third
end

#each(&block) ⇒ Object



59
60
61
62
63
# File 'lib/static_ruby.rb', line 59

def each(&block)
  block.call(@first)
  block.call(@second)
  block.call(@third)
end

#to_aObject



43
44
45
# File 'lib/static_ruby.rb', line 43

def to_a
  [@first, @second, @third]
end

#to_sObject



47
48
49
# File 'lib/static_ruby.rb', line 47

def to_s
  "Triple(#{@first} #{@second} #{@third})"
end