Class: XRay::CSS::Directive

Inherits:
Node
  • Object
show all
Defined in:
lib/css/struct.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyword, expression, block = nil) ⇒ Directive

Returns a new instance of Directive.



36
37
38
# File 'lib/css/struct.rb', line 36

def initialize(keyword, expression, block = nil)
  @keyword, @expression, @block = keyword, expression, block 
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



34
35
36
# File 'lib/css/struct.rb', line 34

def block
  @block
end

#expressionObject (readonly)

Returns the value of attribute expression.



34
35
36
# File 'lib/css/struct.rb', line 34

def expression
  @expression
end

#keywordObject (readonly)

Returns the value of attribute keyword.



34
35
36
# File 'lib/css/struct.rb', line 34

def keyword
  @keyword
end

Instance Method Details

#positionObject



53
54
55
# File 'lib/css/struct.rb', line 53

def position
  keyword.position
end

#textObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/css/struct.rb', line 40

def text
  t = "@#{keyword}"
  if expression
    t += "#{expression}"
  end
  if block
    t += "{\n#{block}\n}\n"
  else
    t += ';'
  end
  t
end