Class: Shortwave::Facade::Build::RemoteMethod
- Inherits:
-
Object
- Object
- Shortwave::Facade::Build::RemoteMethod
- Defined in:
- lib/shortwave/facade/build/facade_builder.rb
Overview
Represents an available method in the Last FM 'rest' api. Provides information about how to call the method.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#http_method ⇒ Object
readonly
Returns the value of attribute http_method.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#remote_name ⇒ Object
readonly
Returns the value of attribute remote_name.
-
#sample_response ⇒ Object
readonly
Returns the value of attribute sample_response.
Instance Method Summary collapse
-
#initialize(html) ⇒ RemoteMethod
constructor
Creates a RemoteMethod, given an html page from the Last FM API documentation.
Constructor Details
#initialize(html) ⇒ RemoteMethod
Creates a RemoteMethod, given an html page from the Last FM API documentation.
186 187 188 189 190 191 192 193 194 195 |
# File 'lib/shortwave/facade/build/facade_builder.rb', line 186 def initialize(html) doc = Nokogiri::HTML(html) @remote_name = doc.css(METHOD_NAME_CSS).text.strip @name = @remote_name.sub(STARTS_WITH_GET,'').camel_to_snake.to_sym @parameters = Parameter.parse(doc) @description = doc.css(DESCRIPTION_CSS).text.strip.gsub(/\s+/, ' ') @http_method = doc.css(METHOD_TYPE_CSS).text.include?("HTTP POST") ? :post : :get @sample_response = doc.css(SAMPLE_CSS).text.strip end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
183 184 185 |
# File 'lib/shortwave/facade/build/facade_builder.rb', line 183 def description @description end |
#http_method ⇒ Object (readonly)
Returns the value of attribute http_method.
183 184 185 |
# File 'lib/shortwave/facade/build/facade_builder.rb', line 183 def http_method @http_method end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
183 184 185 |
# File 'lib/shortwave/facade/build/facade_builder.rb', line 183 def name @name end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
183 184 185 |
# File 'lib/shortwave/facade/build/facade_builder.rb', line 183 def parameters @parameters end |
#remote_name ⇒ Object (readonly)
Returns the value of attribute remote_name.
183 184 185 |
# File 'lib/shortwave/facade/build/facade_builder.rb', line 183 def remote_name @remote_name end |
#sample_response ⇒ Object (readonly)
Returns the value of attribute sample_response.
183 184 185 |
# File 'lib/shortwave/facade/build/facade_builder.rb', line 183 def sample_response @sample_response end |