Class: Wukong::FlatPack::Tokens::BoolToken
- Inherits:
-
BasicToken
- Object
- Token
- BasicToken
- Wukong::FlatPack::Tokens::BoolToken
- Defined in:
- lib/wukong/model/flatpack_parser/tokens.rb
Constant Summary collapse
- TRUE_TOKENS =
['t','y','1']
- FALSE_TOKENS =
['f','n','0']
Instance Attribute Summary
Attributes inherited from BasicToken
Attributes inherited from Token
#indicator, #length, #position
Instance Method Summary collapse
-
#re ⇒ Object
TODO: Add back multi-char options and think through allowing padding TODO: Allow users to override true and false.
- #translate(str) ⇒ Object
Methods inherited from Token
Instance Method Details
#re ⇒ Object
TODO: Add back multi-char options and think through allowing padding TODO: Allow users to override true and false
104 105 106 107 |
# File 'lib/wukong/model/flatpack_parser/tokens.rb', line 104 def re return "(?:#{(TRUE_TOKENS + TRUE_TOKENS.map {|c| c.upcase} + FALSE_TOKENS + FALSE_TOKENS.map{|c| c.upcase}).join('|')})" end |
#translate(str) ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/wukong/model/flatpack_parser/tokens.rb', line 109 def translate str if TRUE_TOKENS.include?(str.downcase) return true elsif FALSE_TOKENS.include?(str.downcase) return false else return nil end end |