Class: Raml::PropertiesNode

Inherits:
Node
  • Object
show all
Defined in:
lib/raml/node.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#name, #parent

Instance Method Summary collapse

Methods inherited from Node

#document, relative_path

Constructor Details

#initialize(name, properties, parent) ⇒ PropertiesNode

Returns a new instance of PropertiesNode.



150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/raml/node.rb', line 150

def initialize(name, properties, parent)
  if name.is_a? String and name.end_with? '?'
    allow_optional? parent
    name = name.dup.chomp! '?'
    @optional = true
  else
    @optional = false
  end

  super name, parent

  @children ||= []
  parse_and_validate_props properties
end

Instance Attribute Details

#optionalBoolean

Returns whether the property is optional. Only valid for decendant nodes a Trait::Instance or ResourceType::Instance. Indicated by a trailing “?” on the property name in the RAML source.

Returns:

  • (Boolean)

    whether the property is optional. Only valid for decendant nodes a Trait::Instance or ResourceType::Instance. Indicated by a trailing “?” on the property name in the RAML source.



148
149
150
# File 'lib/raml/node.rb', line 148

def optional
  @optional
end

Instance Method Details

#_regexp_propertyObject



142
# File 'lib/raml/node.rb', line 142

def _regexp_property     ; self.class._regexp_property     ; end

#non_scalar_propertiesObject



140
# File 'lib/raml/node.rb', line 140

def non_scalar_properties; self.class.non_scalar_properties; end

#scalar_propertiesObject



138
# File 'lib/raml/node.rb', line 138

def scalar_properties    ; self.class.scalar_properties    ; end