Class: HCast::Metadata::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/hcast/metadata/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, caster, options) ⇒ Attribute

Returns a new instance of Attribute.



6
7
8
9
10
11
# File 'lib/hcast/metadata/attribute.rb', line 6

def initialize(name, caster, options)
  @name      = name
  @caster    = caster
  @options   = options
  @children  = []
end

Instance Attribute Details

#casterObject (readonly)

Returns the value of attribute caster.



3
4
5
# File 'lib/hcast/metadata/attribute.rb', line 3

def caster
  @caster
end

#childrenObject

Returns the value of attribute children.



4
5
6
# File 'lib/hcast/metadata/attribute.rb', line 4

def children
  @children
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/hcast/metadata/attribute.rb', line 3

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/hcast/metadata/attribute.rb', line 3

def options
  @options
end

Instance Method Details

#allow_nil?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/hcast/metadata/attribute.rb', line 25

def allow_nil?
  !!options[:allow_nil]
end

#has_children?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/hcast/metadata/attribute.rb', line 13

def has_children?
  !children.empty?
end

#optional?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/hcast/metadata/attribute.rb', line 21

def optional?
  !!options[:optional]
end

#required?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/hcast/metadata/attribute.rb', line 17

def required?
  !optional?
end