Class: HatenablogPublisher::Image
- Inherits:
-
Object
- Object
- HatenablogPublisher::Image
- Defined in:
- lib/hatenablog_publisher/image.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(filepath) ⇒ Image
constructor
A new instance of Image.
- #mime_type ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(filepath) ⇒ Image
Returns a new instance of Image.
8 9 10 |
# File 'lib/hatenablog_publisher/image.rb', line 8 def initialize(filepath) @filepath = filepath end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
6 7 8 |
# File 'lib/hatenablog_publisher/image.rb', line 6 def filepath @filepath end |
Instance Method Details
#content ⇒ Object
16 17 18 |
# File 'lib/hatenablog_publisher/image.rb', line 16 def content Base64.encode64(File.read(@filepath)) end |
#mime_type ⇒ Object
12 13 14 |
# File 'lib/hatenablog_publisher/image.rb', line 12 def mime_type MIME::Types.type_for(@filepath).first end |
#title ⇒ Object
20 21 22 |
# File 'lib/hatenablog_publisher/image.rb', line 20 def title File.basename(@filepath, '.*') end |