Class: Apipie::SeeDescription
- Inherits:
-
Object
- Object
- Apipie::SeeDescription
- Defined in:
- lib/apipie/see_description.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
Instance Method Summary collapse
-
#initialize(args) ⇒ SeeDescription
constructor
A new instance of SeeDescription.
- #see_url ⇒ Object
- #to_json ⇒ Object
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
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/apipie/see_description.rb', line 5 def description @description end |
#link ⇒ Object (readonly)
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_url ⇒ Object
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_json ⇒ Object
25 26 27 |
# File 'lib/apipie/see_description.rb', line 25 def to_json {:link => see_url, :description => description} end |