Module: ScaffoldParser::Scaffolders::XSD::Parser::Handlers::BaseMethod

Included in:
AtMethod, ListMethod, ProxyListMethod, SubmodelMethod
Defined in:
lib/scaffold_parser/scaffolders/xsd/parser/handlers/base_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



7
8
9
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/base_method.rb', line 7

def source
  @source
end

Instance Method Details

#==(other) ⇒ Object



32
33
34
35
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/base_method.rb', line 32

def ==(other)
  method_name == other.method_name &&
    method_body == other.method_body
end

#initialize(source) ⇒ Object



9
10
11
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/base_method.rb', line 9

def initialize(source)
  @source = source
end

#method_nameObject



13
14
15
16
17
18
19
20
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/base_method.rb', line 13

def method_name
  if source.name
    source.name.underscore
  elsif source.ref
    prefix, name = source.ref.split(':')
    name.underscore
  end
end

#to_sObject



22
23
24
25
26
27
28
29
30
# File 'lib/scaffold_parser/scaffolders/xsd/parser/handlers/base_method.rb', line 22

def to_s
  f = StringIO.new

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

  f.string.strip
end