Class: Seahorse::Model::Shapes::StructureShape
- Defined in:
- lib/seahorse/model/shapes.rb
Instance Attribute Summary collapse
Attributes inherited from Shape
Instance Method Summary collapse
- #add_member(name, shape_ref) ⇒ Object
-
#initialize(options = {}) ⇒ StructureShape
constructor
A new instance of StructureShape.
- #member(name) ⇒ ShapeRef
-
#member?(member_name) ⇒ Boolean
Returns ‘true` if there exists a member with the given name.
- #member_by_location_name(location_name) ⇒ Object private
- #member_names ⇒ Array<Symbol>
- #members ⇒ Enumerator<[Symbol,ShapeRef]>
Methods inherited from Shape
Constructor Details
#initialize(options = {}) ⇒ StructureShape
Returns a new instance of StructureShape.
211 212 213 214 215 216 |
# File 'lib/seahorse/model/shapes.rb', line 211 def initialize( = {}) @members = {} @members_by_location_name = {} @required = Set.new super end |
Instance Attribute Details
#required ⇒ Set<Symbol>
219 220 221 |
# File 'lib/seahorse/model/shapes.rb', line 219 def required @required end |
#struct_class ⇒ Class<Struct>
222 223 224 |
# File 'lib/seahorse/model/shapes.rb', line 222 def struct_class @struct_class end |
Instance Method Details
#add_member(name, shape_ref) ⇒ Object
226 227 228 229 230 231 |
# File 'lib/seahorse/model/shapes.rb', line 226 def add_member(name, shape_ref) name = name.to_sym @required << name if shape_ref.required @members_by_location_name[shape_ref.location_name] = [name, shape_ref] @members[name] = shape_ref end |
#member(name) ⇒ ShapeRef
252 253 254 255 256 257 258 |
# File 'lib/seahorse/model/shapes.rb', line 252 def member(name) if member?(name) @members[name.to_sym] else raise ArgumentError, "no such member #{name.inspect}" end end |
#member?(member_name) ⇒ Boolean
Returns ‘true` if there exists a member with the given name.
241 242 243 |
# File 'lib/seahorse/model/shapes.rb', line 241 def member?(member_name) @members.key?(member_name.to_sym) end |
#member_by_location_name(location_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
261 262 263 |
# File 'lib/seahorse/model/shapes.rb', line 261 def member_by_location_name(location_name) @members_by_location_name[location_name] end |
#member_names ⇒ Array<Symbol>
234 235 236 |
# File 'lib/seahorse/model/shapes.rb', line 234 def member_names @members.keys end |
#members ⇒ Enumerator<[Symbol,ShapeRef]>
246 247 248 |
# File 'lib/seahorse/model/shapes.rb', line 246 def members @members.to_enum end |