Class: XmlTagCommandHandler

Inherits:
Object
  • Object
show all
Includes:
CommandHandler
Defined in:
lib/xml_command_handlers/xml_tag_command_handler.rb

Instance Method Summary collapse

Instance Method Details

#can_handle?(parent, command_symbol, *args, &block) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
# File 'lib/xml_command_handlers/xml_tag_command_handler.rb', line 8

def can_handle?(parent, command_symbol, *args, &block)
  (parent == nil or parent.is_a?(Node)) and
  (command_symbol.to_s == "tag") and
  ((args.size == 1) and ((args[0].is_a?(Hash)) or (args[0].is_a?(Hash)))) and
  args[0].include?(:_name)
end

#do_handle(parent, command_symbol, *args, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/xml_command_handlers/xml_tag_command_handler.rb', line 15

def do_handle(parent, command_symbol, *args, &block)
  attributes = nil
  attributes = args[0] if (args.size == 1) 
  tag_name = attributes[:_name]
  attributes.delete(:_name)
  Node.new(parent, tag_name, attributes, &block)
end