Class: EbookReader

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ EbookReader

Returns a new instance of EbookReader.



113
114
115
# File 'lib/instapaper_download.rb', line 113

def initialize(path)
  @mount_point = path
end

Instance Attribute Details

#mount_pointObject (readonly)

Returns the value of attribute mount_point.



111
112
113
# File 'lib/instapaper_download.rb', line 111

def mount_point
  @mount_point
end

Class Method Details

.from_config_file(config_file = ConfigFile.new) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/instapaper_download.rb', line 117

def self.from_config_file(config_file = ConfigFile.new)
  config = {}
  config = config_file.read_from_file if config_file.exists?
  unless config[:ebook_reader_path]
    print "Where is your ebook reader mounted?: "
    path = gets.chomp
    config[:ebook_reader_path] = path
    config_file.save_to_file_if_necessary(config) 
  end
  return EbookReader.new(config[:ebook_reader_path])
end

Instance Method Details

#is_mounted?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/instapaper_download.rb', line 129

def is_mounted?
  File.exists?(@mount_point) and File.directory?(@mount_point)
end

#move_to_device(file) ⇒ Object



133
134
135
136
137
138
139
# File 'lib/instapaper_download.rb', line 133

def move_to_device(file)
  raise %Q{The ebook reader does not seem to be mounted on "#{@mount_point}"} unless is_mounted?
  file = File.expand_path(file)
  @mount_point = File.expand_path(@mount_point)
  FileUtils.mv(file, @mount_point)
  puts %Q{Moved "#{file}" to your ebook reader}
end