Class: ApipieBindings::Param

Inherits:
Object
  • Object
show all
Defined in:
lib/apipie_bindings/param.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param) ⇒ Param

Returns a new instance of Param.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/apipie_bindings/param.rb', line 7

def initialize(param)
  param = ApipieBindings::IndifferentHash.new(param)
  @name = param[:name]
  params = param[:params] || []
  @params = params.map { |p| ApipieBindings::Param.new(p) }
  @expected_type = param[:expected_type].to_sym
  @description = param[:description].gsub(/<\/?[^>]+?>/, "")
  @required = !!param[:required]
  @validator = param[:validator]
  # We expect a value from API param docs, but in case it's not there, we want to show it in help by default
  @show = param[:show].nil? ? true : param[:show]
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/apipie_bindings/param.rb', line 5

def description
  @description
end

#expected_typeObject (readonly)

Returns the value of attribute expected_type.



5
6
7
# File 'lib/apipie_bindings/param.rb', line 5

def expected_type
  @expected_type
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/apipie_bindings/param.rb', line 5

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



5
6
7
# File 'lib/apipie_bindings/param.rb', line 5

def params
  @params
end

#validatorObject (readonly)

Returns the value of attribute validator.



5
6
7
# File 'lib/apipie_bindings/param.rb', line 5

def validator
  @validator
end

Instance Method Details

#inspectObject



32
33
34
# File 'lib/apipie_bindings/param.rb', line 32

def inspect
  to_s
end

#required?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/apipie_bindings/param.rb', line 20

def required?
  @required
end

#show?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/apipie_bindings/param.rb', line 24

def show?
  @show
end

#to_sObject



28
29
30
# File 'lib/apipie_bindings/param.rb', line 28

def to_s
  "<Param #{ required? ? '*' : '' }#{@name} (#{@expected_type.to_s.capitalize})>"
end