Class: RspecGenerateDoc::Decorators::Parameter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Parameter

Returns a new instance of Parameter.



6
7
8
9
10
11
# File 'lib/rspec_generate_doc/decorators/parameter.rb', line 6

def initialize(data = {})
  @name = data[:name] || data['name']
  @required = data[:required] || data['required']
  @description = data[:description] || data['description'] || name || ''
  @options = OpenStruct.new(data[:options] || data['options'] || {})
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/rspec_generate_doc/decorators/parameter.rb', line 4

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/rspec_generate_doc/decorators/parameter.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/rspec_generate_doc/decorators/parameter.rb', line 4

def options
  @options
end

#requiredObject (readonly)

Returns the value of attribute required.



4
5
6
# File 'lib/rspec_generate_doc/decorators/parameter.rb', line 4

def required
  @required
end

Instance Method Details

#required_humanObject



13
14
15
16
# File 'lib/rspec_generate_doc/decorators/parameter.rb', line 13

def required_human
  return required unless !!required == required
  required ? I18n.t(:required_yes, scope: :rspec_api_docs) : I18n.t(:required_no, scope: :rspec_api_docs)
end