Class: ScaffoldParser::Scaffolders::XSD::Parser::Handlers::AtMethod

Inherits:
Object
  • Object
show all
Includes:
BaseMethod, Utils
Defined in:
lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb

Instance Attribute Summary

Attributes included from BaseMethod

#source

Instance Method Summary collapse

Methods included from Utils

#indent, #indent_string, #single_quote, #wrap_in_namespace

Methods included from BaseMethod

#==, #initialize, #method_name

Instance Method Details

#all(_) ⇒ Object



51
52
53
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb', line 51

def all(_)
  All.new self
end

#atObject



30
31
32
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb', line 30

def at
  [source.xmlns_prefix, "#{source.name}"].compact.join(':')
end

#choice(_) ⇒ Object



47
48
49
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb', line 47

def choice(_)
  Choice.new self
end

#method_bodyObject



26
27
28
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb', line 26

def method_body
  "at '#{at}'"
end

#sequence(_) ⇒ Object



43
44
45
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb', line 43

def sequence(_)
  Sequence.new self
end

#to_builderObject



39
40
41
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb', line 39

def to_builder
  "root << build_element('#{at}', data[:#{method_name}], data[:#{method_name}_attributes]) if data.key? :#{method_name}"
end

#to_h_methodObject



34
35
36
37
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb', line 34

def to_h_method
  "hash[:#{method_name}] = #{method_name} if has? '#{at}'\n"\
    "hash[:#{method_name}_attributes] = #{method_name}_attributes if has? '#{at}'"
end

#to_sObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/at_method.rb', line 10

def to_s
  f = StringIO.new

  f.puts "def #{method_name}"
  f.puts indent(method_body.lines).join
  f.puts "end"

  f.puts

  f.puts "def #{method_name}_attributes"
  f.puts "  attributes_at '#{at}'"
  f.puts "end"

  f.string.strip
end