Class: GitHubMarkdownAPI::APIClient Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/github_markdown_api/api_client.rb

Overview

This class is abstract.

Abstract class of API Clients

Direct Known Subclasses

Raw

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}, sub_args = {}) ⇒ APIClient

Returns a new instance of APIClient.

Parameters:

  • args (Hash, String) (defaults to: {})


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_typeString

Returns HTTP ContentType.

Returns:

  • (String)

    HTTP ContentType



37
38
39
# File 'lib/github_markdown_api/api_client.rb', line 37

def content_type
  @content_type
end

#endpointsHash

Returns Endpoint (Server path of API).

Returns:

  • (Hash)

    Endpoint (Server path of API)



34
35
36
# File 'lib/github_markdown_api/api_client.rb', line 34

def endpoints
  @endpoints
end

#hostString

Returns Hostname.

Returns:

  • (String)

    Hostname



28
29
30
# File 'lib/github_markdown_api/api_client.rb', line 28

def host
  @host
end

#last_responseObject (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

#portFixnum

Returns Port number.

Returns:

  • (Fixnum)

    Port number



31
32
33
# File 'lib/github_markdown_api/api_client.rb', line 31

def port
  @port
end

#schemeSymbol

Note:

:http of :https

Returns Scheme of API.

Returns:

  • (Symbol)

    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

Parameters:

  • markdown (String)

Raises:

  • (NotImplementedError)


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

Parameters:

  • args (Hash)

Returns:

  • (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 = default_options.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