Class: AssetsMapper::Enum
- Inherits:
-
Object
- Object
- AssetsMapper::Enum
- Defined in:
- lib/classes/Enum.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#indent_prefix ⇒ Object
writeonly
Sets the attribute indent_prefix.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #add_children(child) ⇒ Object
-
#initialize(name) ⇒ Enum
constructor
A new instance of Enum.
- #to_s ⇒ Object
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
#children ⇒ Object (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
11 12 13 |
# File 'lib/classes/Enum.rb', line 11 def indent_prefix=(value) @indent_prefix = value end |
#name ⇒ Object (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_s ⇒ Object
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 |