Class: HatenablogPublisher::Entry
- Inherits:
-
Object
- Object
- HatenablogPublisher::Entry
- Includes:
- RequestLogger
- Defined in:
- lib/hatenablog_publisher/entry.rb
Constant Summary collapse
- ENDPOINT =
'https://blog.hatena.ne.jp'.freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(context, options) ⇒ Entry
constructor
A new instance of Entry.
- #post_entry(body) ⇒ Object
Methods included from RequestLogger
Constructor Details
#initialize(context, options) ⇒ Entry
Returns a new instance of Entry.
12 13 14 15 16 |
# File 'lib/hatenablog_publisher/entry.rb', line 12 def initialize(context, ) @client = HatenablogPublisher::Api.new(ENDPOINT) @context = context @options = end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/hatenablog_publisher/entry.rb', line 8 def client @client end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/hatenablog_publisher/entry.rb', line 8 def context @context end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/hatenablog_publisher/entry.rb', line 8 def @options end |
Instance Method Details
#post_entry(body) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hatenablog_publisher/entry.rb', line 18 def post_entry(body) request_xml = format_request(body) basename = File.basename(@options.filename) res = with_logging_request(basename, request_xml) do method = @context.hatena.dig(:id) ? :put : :post @client.request(api_url, request_xml, method) end parse_response(res.body) end |