Class: GoonModelGen::Golang::Enum
- Defined in:
- lib/goon_model_gen/golang/enum.rb
Defined Under Namespace
Classes: Element
Instance Attribute Summary collapse
-
#base_type ⇒ Object
readonly
Returns the value of attribute base_type.
-
#base_type_name ⇒ Object
readonly
Returns the value of attribute base_type_name.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Attributes inherited from Type
Instance Method Summary collapse
- #add(value, name) ⇒ Object
- #each_value_and_name {|value, name| ... } ⇒ Object
-
#initialize(name, base_type_name) ⇒ Enum
constructor
A new instance of Enum.
- #resolve(pkgs) ⇒ Object
Methods inherited from Type
Constructor Details
#initialize(name, base_type_name) ⇒ Enum
Returns a new instance of Enum.
20 21 22 23 24 |
# File 'lib/goon_model_gen/golang/enum.rb', line 20 def initialize(name, base_type_name) super(name) @base_type_name = base_type_name @elements = [] end |
Instance Attribute Details
#base_type ⇒ Object (readonly)
Returns the value of attribute base_type.
16 17 18 |
# File 'lib/goon_model_gen/golang/enum.rb', line 16 def base_type @base_type end |
#base_type_name ⇒ Object (readonly)
Returns the value of attribute base_type_name.
15 16 17 |
# File 'lib/goon_model_gen/golang/enum.rb', line 15 def base_type_name @base_type_name end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
15 16 17 |
# File 'lib/goon_model_gen/golang/enum.rb', line 15 def elements @elements end |
Instance Method Details
#add(value, name) ⇒ Object
28 29 30 |
# File 'lib/goon_model_gen/golang/enum.rb', line 28 def add(value, name) elements << Element.new(value, name) end |
#each_value_and_name {|value, name| ... } ⇒ Object
34 35 36 37 38 |
# File 'lib/goon_model_gen/golang/enum.rb', line 34 def each_value_and_name elements.each do |i| yield(i.value, i.name) end end |
#resolve(pkgs) ⇒ Object
41 42 43 |
# File 'lib/goon_model_gen/golang/enum.rb', line 41 def resolve(pkgs) @base_type = pkgs.type_for(base_type_name) || raise("#{base_type_name.inspect} not found for #{name}") end |