Class: FFI::Generator::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/generator/node.rb

Direct Known Subclasses

Constant, Enum, Type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = { }) ⇒ Node

Returns a new instance of Node.



5
6
7
8
9
10
# File 'lib/generator/node.rb', line 5

def initialize(params = { })
  params = { :indent => 0 }.merge(params)
  @node, @indent = params[:node], params[:indent]
  @indent_str = ' ' * @indent
  @symname = get_attr('name')
end

Instance Attribute Details

#symnameObject (readonly)

Returns the value of attribute symname.



4
5
6
# File 'lib/generator/node.rb', line 4

def symname
  @symname
end

Instance Method Details

#get_attr(name) ⇒ Object



11
12
13
14
15
16
# File 'lib/generator/node.rb', line 11

def get_attr(name)
  if @node
    attr = (@node / "./attributelist/attribute[@name='#{name}']").first
    attr['value'] if attr
  end
end