Class: XDry::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/xdry/parsing/nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

Returns a new instance of Node.



7
8
9
# File 'lib/xdry/parsing/nodes.rb', line 7

def initialize
  @tags = Set.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args, &block) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/xdry/parsing/nodes.rb', line 27

def method_missing id, *args, &block
  if id.to_s =~ /^with_(.*)$/
    send("#{$1}=", *args, &block)
    self
  else
    super(id, *args, &block)
  end
end

Instance Attribute Details

#indentObject

Returns the value of attribute indent.



5
6
7
# File 'lib/xdry/parsing/nodes.rb', line 5

def indent
  @indent
end

#posObject

Returns the value of attribute pos.



5
6
7
# File 'lib/xdry/parsing/nodes.rb', line 5

def pos
  @pos
end

Instance Method Details

#tagged_with?(tag) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/xdry/parsing/nodes.rb', line 19

def tagged_with? tag
  @tags.include? tag
end

#tagsObject



11
12
13
# File 'lib/xdry/parsing/nodes.rb', line 11

def tags
  @tags.dup
end

#tags=(new_tags) ⇒ Object



15
16
17
# File 'lib/xdry/parsing/nodes.rb', line 15

def tags= new_tags
  @tags = Set.new(new_tags)
end

#tags_commentObject



23
24
25
# File 'lib/xdry/parsing/nodes.rb', line 23

def tags_comment
  if @tags.empty? then "" else " // " + @tags.to_a.sort.join(", ") end
end