Class: Apipie::SeeDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/apipie/see_description.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ SeeDescription

Returns a new instance of SeeDescription.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/apipie/see_description.rb', line 7

def initialize(args)
  if args.first.is_a? Hash
    args = args.first
  elsif args.count == 2
    if args.last.is_a? Hash
      args = {:link => args.first}.merge(args.last)
    else
      args = {:link => args.first, :description => args.second}
    end
  elsif args.count == 1 && args.first.is_a?(String)
    args = {:link => args.first, :description => args.first}
  else
    raise ArgumentError "ApipieError: Bad use of see method."
  end
  @link = args[:link] || args['link']
  @description = args[:desc] || args[:description] || args['desc'] || args['description']
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/apipie/see_description.rb', line 5

def description
  @description
end

Returns the value of attribute link.



5
6
7
# File 'lib/apipie/see_description.rb', line 5

def link
  @link
end

Instance Method Details

#see_urlObject



29
30
31
32
33
34
35
# File 'lib/apipie/see_description.rb', line 29

def see_url
  method_description = Apipie[@link]
  if method_description.nil?
    raise ArgumentError.new("Method #{@link} referenced in 'see' does not exist.")
  end
  method_description.doc_url
end

#to_jsonObject



25
26
27
# File 'lib/apipie/see_description.rb', line 25

def to_json
  {:link => see_url, :description => description}
end