Class: AssetsMapper::Enum

Inherits:
Object
  • Object
show all
Defined in:
lib/classes/Enum.rb

Direct Known Subclasses

RecurseEnum

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Enum

Returns a new instance of Enum.



12
13
14
15
16
# File 'lib/classes/Enum.rb', line 12

def initialize(name)
  @name = name
  @children = []
  @indent_prefix = ""
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



10
11
12
# File 'lib/classes/Enum.rb', line 10

def children
  @children
end

#indent_prefix=(value) ⇒ Object (writeonly)

Sets the attribute indent_prefix

Parameters:

  • value

    the value to set the attribute indent_prefix to.



11
12
13
# File 'lib/classes/Enum.rb', line 11

def indent_prefix=(value)
  @indent_prefix = value
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/classes/Enum.rb', line 10

def name
  @name
end

Class Method Details

.static_let(key, value) ⇒ Object



5
6
7
# File 'lib/classes/Enum.rb', line 5

def static_let(key, value)
  "static let #{key} = \"#{value}\"\n"
end

Instance Method Details

#add_children(child) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/classes/Enum.rb', line 18

def add_children(child)
  if child.class == String
    @children.push("    " + child)
  elsif child.class == Enum
    child.indent_prefix = "    "
    @children.push(child)
  else
    raise "Must be String or Enum"
  end
end

#to_sObject



30
31
32
33
34
35
36
# File 'lib/classes/Enum.rb', line 30

def to_s
  s = @indent_prefix + "enum #{@name} {\n"
  @children.each do |x|
    s = s + @indent_prefix + x.to_s
  end
  s = s + @indent_prefix + "}\n"
end