Class: Codabel::Type::Flag

Inherits:
Codabel::Type show all
Defined in:
lib/codabel/type/flag.rb

Instance Method Summary collapse

Methods inherited from Codabel::Type

#check!

Constructor Details

#initialize(when_true: '1', when_false: '0') ⇒ Flag

Returns a new instance of Flag.

[View source]

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

[View source]

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