Class: Sangi::Rod
- Inherits:
-
Object
- Object
- Sangi::Rod
- Defined in:
- lib/sangi/rod.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
Instance Method Summary collapse
-
#initialize(id:, kind:) ⇒ Rod
constructor
A new instance of Rod.
- #value ⇒ Object
Constructor Details
#initialize(id:, kind:) ⇒ Rod
Returns a new instance of Rod.
5 6 7 8 9 10 |
# File 'lib/sangi/rod.rb', line 5 def initialize(id:, kind:) raise ValidationError, "invalid rod kind" unless %i[unit five].include?(kind) @id = id @kind = kind end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/sangi/rod.rb', line 3 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
3 4 5 |
# File 'lib/sangi/rod.rb', line 3 def kind @kind end |
Instance Method Details
#value ⇒ Object
12 13 14 |
# File 'lib/sangi/rod.rb', line 12 def value kind == :five ? 5 : 1 end |