Class: SyntaxSuggest::LexValue
- Inherits:
-
Object
- Object
- SyntaxSuggest::LexValue
- Defined in:
- lib/syntax_suggest/lex_value.rb
Overview
Value object for accessing lex values
This lex:
[1, 0], :on_ident, "describe", CMDARG
Would translate into:
lex.line # => 1
lex.type # => :on_indent
lex.token # => "describe"
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #expr_beg? ⇒ Boolean
- #expr_label? ⇒ Boolean
- #fname? ⇒ Boolean
- #ignore_newline? ⇒ Boolean
-
#initialize(line, type, token, state, last_lex = nil) ⇒ LexValue
constructor
A new instance of LexValue.
- #is_end? ⇒ Boolean
- #is_kw? ⇒ Boolean
Constructor Details
#initialize(line, type, token, state, last_lex = nil) ⇒ LexValue
Returns a new instance of LexValue.
18 19 20 21 22 23 24 25 |
# File 'lib/syntax_suggest/lex_value.rb', line 18 def initialize(line, type, token, state, last_lex = nil) @line = line @type = type @token = token @state = state set_kw_end(last_lex) end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
16 17 18 |
# File 'lib/syntax_suggest/lex_value.rb', line 16 def line @line end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
16 17 18 |
# File 'lib/syntax_suggest/lex_value.rb', line 16 def state @state end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
16 17 18 |
# File 'lib/syntax_suggest/lex_value.rb', line 16 def token @token end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
16 17 18 |
# File 'lib/syntax_suggest/lex_value.rb', line 16 def type @type end |
Instance Method Details
#expr_beg? ⇒ Boolean
62 63 64 |
# File 'lib/syntax_suggest/lex_value.rb', line 62 def expr_beg? state.anybits?(Ripper::EXPR_BEG) end |
#expr_label? ⇒ Boolean
66 67 68 |
# File 'lib/syntax_suggest/lex_value.rb', line 66 def expr_label? state.allbits?(Ripper::EXPR_LABEL) end |
#fname? ⇒ Boolean
46 47 48 |
# File 'lib/syntax_suggest/lex_value.rb', line 46 def fname? state.allbits?(Ripper::EXPR_FNAME) end |
#ignore_newline? ⇒ Boolean
50 51 52 |
# File 'lib/syntax_suggest/lex_value.rb', line 50 def ignore_newline? type == :on_ignored_nl end |
#is_end? ⇒ Boolean
54 55 56 |
# File 'lib/syntax_suggest/lex_value.rb', line 54 def is_end? @is_end end |
#is_kw? ⇒ Boolean
58 59 60 |
# File 'lib/syntax_suggest/lex_value.rb', line 58 def is_kw? @is_kw end |