Class: Dryml::Parser::Attribute

Inherits:
REXML::Attribute
  • Object
show all
Defined in:
lib/dryml/parser/attribute.rb

Instance Method Summary collapse

Constructor Details

#initialize(first, second = nil, parent = nil) ⇒ Attribute

Returns a new instance of Attribute.



5
6
7
8
9
10
# File 'lib/dryml/parser/attribute.rb', line 5

def initialize(first, second=nil, parent=nil)
  super
  if first.is_a?(String) && second == true
    @value = true
  end
end

Instance Method Details

#element=(element) ⇒ Object

Override to supress Text.check call



34
35
36
37
# File 'lib/dryml/parser/attribute.rb', line 34

def element=( element )
  @element = element
  self
end

#has_rhs?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/dryml/parser/attribute.rb', line 28

def has_rhs?
  !defined?(@value)
end

#to_stringObject



20
21
22
23
24
25
26
# File 'lib/dryml/parser/attribute.rb', line 20

def to_string
  if has_rhs?
    super
  else
    @expanded_name
  end
end

#valueObject



12
13
14
15
16
17
18
# File 'lib/dryml/parser/attribute.rb', line 12

def value
  if has_rhs?
    super
  else
    element.document.default_attribute_value
  end
end