Class: Ghost::Config
- Inherits:
-
Object
- Object
- Ghost::Config
- Defined in:
- lib/ghost/config.rb
Instance Attribute Summary collapse
-
#api_type ⇒ Object
readonly
Returns the value of attribute api_type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #base_url ⇒ Object
-
#initialize(url:, version:, api_type:, key:) ⇒ Config
constructor
A new instance of Config.
- #resource_email_url(resource, email) ⇒ Object
- #resource_id_url(resource, id) ⇒ Object
- #resource_slug_url(resource, slug) ⇒ Object
- #resource_url(resource) ⇒ Object
Constructor Details
#initialize(url:, version:, api_type:, key:) ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 12 13 14 |
# File 'lib/ghost/config.rb', line 7 def initialize(url:, version:, api_type:, key:) @url = url.to_s.chomp("/") @version = version @api_type = api_type @key = key validate! end |
Instance Attribute Details
#api_type ⇒ Object (readonly)
Returns the value of attribute api_type.
5 6 7 |
# File 'lib/ghost/config.rb', line 5 def api_type @api_type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/ghost/config.rb', line 5 def url @url end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/ghost/config.rb', line 5 def version @version end |
Instance Method Details
#base_url ⇒ Object
16 17 18 |
# File 'lib/ghost/config.rb', line 16 def base_url "#{@url}/ghost/api/#{@api_type}" end |
#resource_email_url(resource, email) ⇒ Object
32 33 34 |
# File 'lib/ghost/config.rb', line 32 def resource_email_url(resource, email) "#{base_url}/#{resource}/email/#{email}/" end |
#resource_id_url(resource, id) ⇒ Object
24 25 26 |
# File 'lib/ghost/config.rb', line 24 def resource_id_url(resource, id) "#{base_url}/#{resource}/#{id}/" end |
#resource_slug_url(resource, slug) ⇒ Object
28 29 30 |
# File 'lib/ghost/config.rb', line 28 def resource_slug_url(resource, slug) "#{base_url}/#{resource}/slug/#{slug}/" end |
#resource_url(resource) ⇒ Object
20 21 22 |
# File 'lib/ghost/config.rb', line 20 def resource_url(resource) "#{base_url}/#{resource}/" end |