Class: Foo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, weight) ⇒ Foo



73
74
75
76
# File 'lib/enumerable_weighted_sample.rb', line 73

def initialize(name, weight)
  self.name = name
  self.weight = weight
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



72
73
74
# File 'lib/enumerable_weighted_sample.rb', line 72

def name
  @name
end

#weightObject

Returns the value of attribute weight.



72
73
74
# File 'lib/enumerable_weighted_sample.rb', line 72

def weight
  @weight
end

Instance Method Details

#inspectObject



80
81
82
# File 'lib/enumerable_weighted_sample.rb', line 80

def inspect
  "#{name}: #{weight}"
end

#to_sObject



77
78
79
# File 'lib/enumerable_weighted_sample.rb', line 77

def to_s
  name
end