Class: Rtml::Rules::DomTag

Inherits:
Object
  • Object
show all
Defined in:
lib/rtml/rules/dom_tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ DomTag

Returns a new instance of DomTag.



6
7
8
9
10
# File 'lib/rtml/rules/dom_tag.rb', line 6

def initialize(name)
  @name = name
  @child_tags = []
  @order = []
end

Instance Attribute Details

#child_tagsObject (readonly)

Returns the value of attribute child_tags.



3
4
5
# File 'lib/rtml/rules/dom_tag.rb', line 3

def child_tags
  @child_tags
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/rtml/rules/dom_tag.rb', line 2

def name
  @name
end

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'lib/rtml/rules/dom_tag.rb', line 4

def order
  @order
end

Instance Method Details

#==(a) ⇒ Object



24
25
26
# File 'lib/rtml/rules/dom_tag.rb', line 24

def ==(a)
  a.kind_of?(String) ? a == name : a.name == name
end

#childrenObject



12
13
14
# File 'lib/rtml/rules/dom_tag.rb', line 12

def children
  child_tags.flatten.select { |t| t.kind_of?(String) }
end

#firstObject

compatiblity with Array; see Tml::Dom::Ruleset



20
21
22
# File 'lib/rtml/rules/dom_tag.rb', line 20

def first
  self
end

#maximum(child_name) ⇒ Object



17
# File 'lib/rtml/rules/dom_tag.rb', line 17

def maximum(child_name) option_for_child(child_name, :maximum) end

#minimum(child_name) ⇒ Object



16
# File 'lib/rtml/rules/dom_tag.rb', line 16

def minimum(child_name) option_for_child(child_name, :minimum) end

#to_sObject



28
29
30
# File 'lib/rtml/rules/dom_tag.rb', line 28

def to_s
  name
end