Class: Typesafe::NoulAnswer
- Defined in:
- lib/typesafe/noul_answer.rb
Overview
Instance Attribute Summary collapse
-
#noul ⇒ Numeric
readonly
The yes/no answer, between 0 (no) and 1 (yes).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(noul:) ⇒ NoulAnswer
constructor
A new instance of NoulAnswer.
- #to_h ⇒ Object
- #type ⇒ Object
Methods inherited from Answer
Constructor Details
#initialize(noul:) ⇒ NoulAnswer
Returns a new instance of NoulAnswer.
14 15 16 17 |
# File 'lib/typesafe/noul_answer.rb', line 14 def initialize(noul:) @noul = validate_probability(noul, "noul") freeze end |
Instance Attribute Details
#noul ⇒ Numeric (readonly)
Returns the yes/no answer, between 0 (no) and 1 (yes).
10 11 12 |
# File 'lib/typesafe/noul_answer.rb', line 10 def noul @noul end |
Class Method Details
.from_h(hash) ⇒ NoulAnswer
22 23 24 |
# File 'lib/typesafe/noul_answer.rb', line 22 def self.from_h(hash) new(noul: hash["noul"] || hash[:noul]) end |
Instance Method Details
#to_h ⇒ Object
30 31 32 |
# File 'lib/typesafe/noul_answer.rb', line 30 def to_h { type: type, noul: noul } end |
#type ⇒ Object
26 27 28 |
# File 'lib/typesafe/noul_answer.rb', line 26 def type "noul" end |