Class: StyleScript::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/style_script/value.rb

Overview

Instead of producing raw Ruby objects, the Lexer produces values of this class, wrapping native objects tagged with line number information. Values masquerade as both strings and nodes – being used both as nodes in the AST, and as literally-interpolated values in the generated code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, line = nil) ⇒ Value

Returns a new instance of Value.



10
11
12
# File 'lib/style_script/value.rb', line 10

def initialize(value, line=nil)
  @value, @line = value, line
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



8
9
10
# File 'lib/style_script/value.rb', line 8

def line
  @line
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/style_script/value.rb', line 8

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



31
32
33
# File 'lib/style_script/value.rb', line 31

def ==(other)
  @value == other
end

#[](index) ⇒ Object



35
36
37
# File 'lib/style_script/value.rb', line 35

def [](index)
  @value[index]
end

#childrenObject



51
52
53
# File 'lib/style_script/value.rb', line 51

def children
  []
end

#compile(o = {}) ⇒ Object



23
24
25
# File 'lib/style_script/value.rb', line 23

def compile(o={})
  to_s
end

#contains?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/style_script/value.rb', line 59

def contains?
  false
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/style_script/value.rb', line 39

def eql?(other)
  @value.eql?(other)
end

#hashObject



43
44
45
# File 'lib/style_script/value.rb', line 43

def hash
  @value.hash
end

#inspectObject



27
28
29
# File 'lib/style_script/value.rb', line 27

def inspect
  @value.inspect
end

#match(regex) ⇒ Object



47
48
49
# File 'lib/style_script/value.rb', line 47

def match(regex)
  @value.match(regex)
end

#statement_only?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/style_script/value.rb', line 55

def statement_only?
  false
end

#to_strObject Also known as: to_s



14
15
16
# File 'lib/style_script/value.rb', line 14

def to_str
  @value.to_s
end

#to_symObject



19
20
21
# File 'lib/style_script/value.rb', line 19

def to_sym
  to_str.to_sym
end