Class: Codshit::Choice

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*choices) ⇒ Choice

Returns a new instance of Choice.



16
17
18
# File 'lib/codshit.rb', line 16

def initialize(*choices)
  @choices = choices
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



14
15
16
# File 'lib/codshit.rb', line 14

def choices
  @choices
end

Instance Method Details

#<<(c) ⇒ Object



28
29
30
# File 'lib/codshit.rb', line 28

def <<(c)
  @choices << c
end

#to_textObject



24
25
26
# File 'lib/codshit.rb', line 24

def to_text
  @choices[rand(@choices.length)].to_text
end

#|(right) ⇒ Object



20
21
22
# File 'lib/codshit.rb', line 20

def |(right)
  self.class.new(*(choices + right.choices))
end