Class: ResoTransport::Enum
- Inherits:
-
Struct
- Object
- Struct
- ResoTransport::Enum
- Defined in:
- lib/reso_transport/enum.rb
Instance Attribute Summary collapse
-
#is_flags ⇒ Object
Returns the value of attribute is_flags.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #encode_value(value) ⇒ Object
- #generate_member_map ⇒ Object
- #mapping ⇒ Object
- #members ⇒ Object
- #parse_value(value) ⇒ Object
Instance Attribute Details
#is_flags ⇒ Object
Returns the value of attribute is_flags
8 9 10 |
# File 'lib/reso_transport/enum.rb', line 8 def is_flags @is_flags end |
#name ⇒ Object
Returns the value of attribute name
8 9 10 |
# File 'lib/reso_transport/enum.rb', line 8 def name @name end |
#type ⇒ Object
Returns the value of attribute type
8 9 10 |
# File 'lib/reso_transport/enum.rb', line 8 def type @type end |
Class Method Details
.from_stream(args) ⇒ Object
9 10 11 |
# File 'lib/reso_transport/enum.rb', line 9 def self.from_stream(args) new("#{args[:schema].namespace}.#{args["Name"]}", args["UnderlyingType"], args["IsFlags"]) end |
Instance Method Details
#encode_value(value) ⇒ Object
21 22 23 |
# File 'lib/reso_transport/enum.rb', line 21 def encode_value(value) "'#{mapping.invert.fetch(value, value)}'" end |
#generate_member_map ⇒ Object
29 30 31 32 33 |
# File 'lib/reso_transport/enum.rb', line 29 def generate_member_map members.map {|mem| { mem.name => mem.annotation || mem.name } }.reduce(:merge!) end |
#mapping ⇒ Object
25 26 27 |
# File 'lib/reso_transport/enum.rb', line 25 def mapping @mapping ||= generate_member_map || {} end |
#members ⇒ Object
13 14 15 |
# File 'lib/reso_transport/enum.rb', line 13 def members @members ||= [] end |
#parse_value(value) ⇒ Object
17 18 19 |
# File 'lib/reso_transport/enum.rb', line 17 def parse_value(value) mapping.fetch(value, value) end |