Class: FFI::Generator::Enum

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

Instance Attribute Summary

Attributes inherited from Node

#symname

Instance Method Summary collapse

Methods inherited from Node

#get_attr

Constructor Details

#initialize(params = { }) ⇒ Enum

Returns a new instance of Enum.



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

def initialize(params = { })
  super
  eval_items
end

Instance Method Details

#to_sObject



8
9
10
11
12
# File 'lib/generator/enum.rb', line 8

def to_s
  @items.sort { |i1, i2| i1[1] <=> i2[1] }.inject("") do |result, item|
    result << assignment_str(item[0], item[1]) << "\n"
  end
end