Class: Codabel::Type::Flag
- Inherits:
-
Codabel::Type
- Object
- Codabel::Type
- Codabel::Type::Flag
- Defined in:
- lib/codabel/type/flag.rb
Instance Method Summary collapse
-
#initialize(when_true: '1', when_false: '0') ⇒ Flag
constructor
A new instance of Flag.
- #to_coda(value, length) ⇒ Object
Methods inherited from Codabel::Type
Constructor Details
#initialize(when_true: '1', when_false: '0') ⇒ Flag
Returns a new instance of Flag.
4 5 6 7 |
# File 'lib/codabel/type/flag.rb', line 4 def initialize(when_true: '1', when_false: '0') @when_true = when_true @when_false = when_false end |
Instance Method Details
#to_coda(value, length) ⇒ Object
9 10 11 12 |
# File 'lib/codabel/type/flag.rb', line 9 def to_coda(value, length) str = value ? @when_true : @when_false str.rjust(length, ' ') end |