Class: Seahorse::Model::Shapes::StructureShape

Inherits:
Shape
  • Object
show all
Defined in:
lib/seahorse/model/shapes.rb

Instance Attribute Summary collapse

Attributes inherited from Shape

#documentation, #name

Instance Method Summary collapse

Methods inherited from Shape

#[], #[]=

Constructor Details

#initialize(options = {}) ⇒ StructureShape

Returns a new instance of StructureShape.



162
163
164
165
166
167
# File 'lib/seahorse/model/shapes.rb', line 162

def initialize(options = {})
  @members = {}
  @members_by_location_name = {}
  @required = Set.new
  super()
end

Instance Attribute Details

#requiredSet<Symbol>

Returns:

  • (Set<Symbol>)


170
171
172
# File 'lib/seahorse/model/shapes.rb', line 170

def required
  @required
end

Instance Method Details

#add_member(name, shape_ref) ⇒ Object

Parameters:



174
175
176
177
178
179
# File 'lib/seahorse/model/shapes.rb', line 174

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

Parameters:

  • name (Symbol)

Returns:



200
201
202
203
204
205
206
# File 'lib/seahorse/model/shapes.rb', line 200

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.

Parameters:

  • member_name (Symbol)

Returns:

  • (Boolean)

    Returns ‘true` if there exists a member with the given name.



189
190
191
# File 'lib/seahorse/model/shapes.rb', line 189

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.



209
210
211
# File 'lib/seahorse/model/shapes.rb', line 209

def member_by_location_name(location_name)
  @members_by_location_name[location_name]
end

#member_namesArray<Symbol>

Returns:

  • (Array<Symbol>)


182
183
184
# File 'lib/seahorse/model/shapes.rb', line 182

def member_names
  @members.keys
end

#membersEnumerator<[Symbol,ShapeRef]>

Returns:



194
195
196
# File 'lib/seahorse/model/shapes.rb', line 194

def members
  @members.to_enum
end