Class: Ripper::Lexer::State

Inherits:
Object show all
Defined in:
ext/ripper/lib/ripper/lexer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(i) ⇒ State

Returns a new instance of State.



59
60
61
62
63
# File 'ext/ripper/lib/ripper/lexer.rb', line 59

def initialize(i)
  @to_int = i
  @to_s = Ripper.lex_state_name(i)
  freeze
end

Instance Attribute Details

#to_intObject (readonly) Also known as: to_i

Returns the value of attribute to_int.



57
58
59
# File 'ext/ripper/lib/ripper/lexer.rb', line 57

def to_int
  @to_int
end

#to_sObject (readonly) Also known as: inspect

Returns the value of attribute to_s.



57
58
59
# File 'ext/ripper/lib/ripper/lexer.rb', line 57

def to_s
  @to_s
end

Instance Method Details

#&(i) ⇒ Object



80
# File 'ext/ripper/lib/ripper/lexer.rb', line 80

def &(i) self.class.new(to_int & i) end

#==(i) ⇒ Object



79
# File 'ext/ripper/lib/ripper/lexer.rb', line 79

def ==(i) super or to_int == i end

#[](index) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'ext/ripper/lib/ripper/lexer.rb', line 65

def [](index)
  case index
  when 0, :to_int
    @to_int
  when 1, :to_s
    @event
  else
    nil
  end
end

#allbits?(i) ⇒ Boolean

Returns:

  • (Boolean)


82
# File 'ext/ripper/lib/ripper/lexer.rb', line 82

def allbits?(i) to_int.allbits?(i) end

#anybits?(i) ⇒ Boolean

Returns:

  • (Boolean)


83
# File 'ext/ripper/lib/ripper/lexer.rb', line 83

def anybits?(i) to_int.anybits?(i) end

#nobits?(i) ⇒ Boolean

Returns:

  • (Boolean)


84
# File 'ext/ripper/lib/ripper/lexer.rb', line 84

def nobits?(i) to_int.nobits?(i) end

#pretty_print(q) ⇒ Object



78
# File 'ext/ripper/lib/ripper/lexer.rb', line 78

def pretty_print(q) q.text(to_s) end

#|(i) ⇒ Object



81
# File 'ext/ripper/lib/ripper/lexer.rb', line 81

def |(i) self.class.new(to_int | i) end