Class: GitHubMarkdownAPI::APIClient Abstract
- Inherits:
-
Object
- Object
- GitHubMarkdownAPI::APIClient
- Defined in:
- lib/github_markdown_api/api_client.rb
Overview
This class is abstract.
Abstract class of API Clients
Direct Known Subclasses
Instance Attribute Summary collapse
-
#content_type ⇒ String
HTTP ContentType.
-
#endpoints ⇒ Hash
Endpoint (Server path of API).
-
#host ⇒ String
Hostname.
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
-
#port ⇒ Fixnum
Port number.
-
#scheme ⇒ Symbol
Scheme of API.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}, sub_args = {}) ⇒ APIClient
constructor
A new instance of APIClient.
-
#render(markdown) ⇒ Object
abstract
Renders HTML from Markdown.
- #set_option(args) ⇒ self
Constructor Details
#initialize(args = {}, sub_args = {}) ⇒ APIClient
Returns a new instance of APIClient.
12 13 14 15 16 17 18 19 |
# File 'lib/github_markdown_api/api_client.rb', line 12 def initialize(args = {}, sub_args = {}) case args when Hash set_option(args) when String # pending end end |
Instance Attribute Details
#content_type ⇒ String
Returns HTTP ContentType.
37 38 39 |
# File 'lib/github_markdown_api/api_client.rb', line 37 def content_type @content_type end |
#endpoints ⇒ Hash
Returns Endpoint (Server path of API).
34 35 36 |
# File 'lib/github_markdown_api/api_client.rb', line 34 def endpoints @endpoints end |
#host ⇒ String
Returns Hostname.
28 29 30 |
# File 'lib/github_markdown_api/api_client.rb', line 28 def host @host end |
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
21 22 23 |
# File 'lib/github_markdown_api/api_client.rb', line 21 def last_response @last_response end |
#port ⇒ Fixnum
Returns Port number.
31 32 33 |
# File 'lib/github_markdown_api/api_client.rb', line 31 def port @port end |
#scheme ⇒ Symbol
Note:
:http
of :https
Returns Scheme of API.
25 26 27 |
# File 'lib/github_markdown_api/api_client.rb', line 25 def scheme @scheme end |
Class Method Details
.render(markdown) ⇒ Object
7 8 9 |
# File 'lib/github_markdown_api/api_client.rb', line 7 def self.render(markdown) new.render(markdown) end |
Instance Method Details
#render(markdown) ⇒ Object
This method is abstract.
Renders HTML from Markdown
56 57 58 |
# File 'lib/github_markdown_api/api_client.rb', line 56 def render(markdown) raise NotImplementedError, "#{__method__} is a abstract method." end |
#set_option(args) ⇒ self
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/github_markdown_api/api_client.rb', line 41 def set_option(args) option = .merge(args) self.scheme = option[:scheme].to_sym self.host = option[:host].to_s self.port = option[:port] self.endpoints = option[:endpoints].to_h self.content_type = option[:content_type].to_s self end |