Class: HatenablogPublisher::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/hatenablog_publisher/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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

#contentObject



16
17
18
# File 'lib/hatenablog_publisher/image.rb', line 16

def content
  Base64.encode64(File.read(@filepath))
end

#mime_typeObject



12
13
14
# File 'lib/hatenablog_publisher/image.rb', line 12

def mime_type
  MIME::Types.type_for(@filepath).first
end

#titleObject



20
21
22
# File 'lib/hatenablog_publisher/image.rb', line 20

def title
  File.basename(@filepath, '.*')
end