Class: Relax::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/relax/parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Parameter

Returns a new instance of Parameter.



6
7
8
9
# File 'lib/relax/parameter.rb', line 6

def initialize(name, options={})
  @name = name
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/relax/parameter.rb', line 3

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/relax/parameter.rb', line 3

def options
  @options
end

#valueObject



15
16
17
# File 'lib/relax/parameter.rb', line 15

def value
  @value || @options[:default]
end

Instance Method Details

#named?(name) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/relax/parameter.rb', line 11

def named?(name)
  name == (@options[:as] || @name)
end

#required?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/relax/parameter.rb', line 19

def required?
  @options[:required]
end