Class: Codshit::Choice
- Inherits:
-
Object
- Object
- Codshit::Choice
- Defined in:
- lib/codshit.rb
Instance Attribute Summary collapse
-
#choices ⇒ Object
readonly
Returns the value of attribute choices.
Instance Method Summary collapse
- #<<(c) ⇒ Object
-
#initialize(*choices) ⇒ Choice
constructor
A new instance of Choice.
- #to_text ⇒ Object
- #|(right) ⇒ Object
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
#choices ⇒ Object (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_text ⇒ Object
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 |