Class: HashSyntax::Token
- Inherits:
-
Struct
- Object
- Struct
- HashSyntax::Token
- Defined in:
- lib/hash_syntax/token.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#col ⇒ Object
Returns the value of attribute col.
-
#line ⇒ Object
Returns the value of attribute line.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(token) ⇒ Token
constructor
Unpacks the token from Ripper and breaks it into its separate components.
- #reg_desc ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(token) ⇒ Token
Unpacks the token from Ripper and breaks it into its separate components.
7 8 9 |
# File 'lib/hash_syntax/token.rb', line 7 def initialize(token) (self.line, self.col), self.type, self.body = token end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
2 3 4 |
# File 'lib/hash_syntax/token.rb', line 2 def body @body end |
#col ⇒ Object
Returns the value of attribute col
2 3 4 |
# File 'lib/hash_syntax/token.rb', line 2 def col @col end |
#line ⇒ Object
Returns the value of attribute line
2 3 4 |
# File 'lib/hash_syntax/token.rb', line 2 def line @line end |
#type ⇒ Object
Returns the value of attribute type
2 3 4 |
# File 'lib/hash_syntax/token.rb', line 2 def type @type end |
Instance Method Details
#reg_desc ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/hash_syntax/token.rb', line 15 def reg_desc if type == :on_op && body == '=>' 'hashrocket' else type.to_s.sub(/^on_/, '') end end |
#width ⇒ Object
11 12 13 |
# File 'lib/hash_syntax/token.rb', line 11 def width body.size end |