Class: MiniCSS::CSS::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/minicss/css/token.rb

Constant Summary collapse

EOF =
Token.new(:eof, nil, nil)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind, pos_start, pos_end, **opts) ⇒ Token

Returns a new instance of Token.



9
10
11
12
13
14
15
# File 'lib/minicss/css/token.rb', line 9

def initialize(kind, pos_start, pos_end, **opts)
  @kind = kind
  @pos_start = pos_start
  @pos_end = pos_end
  @literal = opts.delete(:literal)
  @opts = opts.empty? ? nil : opts
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



6
7
8
# File 'lib/minicss/css/token.rb', line 6

def kind
  @kind
end

#literalObject



17
18
19
20
21
# File 'lib/minicss/css/token.rb', line 17

def literal
  return " " if kind == :whitespace

  @literal
end

#optsObject (readonly)

Returns the value of attribute opts.



6
7
8
# File 'lib/minicss/css/token.rb', line 6

def opts
  @opts
end

#pos_endObject (readonly)

Returns the value of attribute pos_end.



6
7
8
# File 'lib/minicss/css/token.rb', line 6

def pos_end
  @pos_end
end

#pos_startObject (readonly)

Returns the value of attribute pos_start.



6
7
8
# File 'lib/minicss/css/token.rb', line 6

def pos_start
  @pos_start
end

Instance Method Details

#eof?Boolean

Returns:



23
# File 'lib/minicss/css/token.rb', line 23

def eof? = @kind == :eof