Class: Kindle::Settings
- Inherits:
-
Object
- Object
- Kindle::Settings
- Defined in:
- lib/kindle/settings.rb
Constant Summary collapse
- KINDLE_SETTINGS_DIRECTORY =
"#{ENV["HOME"]}/.kindle"
- KINDLE_SETTINGS_FILENAME =
"#{KINDLE_SETTINGS_DIRECTORY}/kindlerc.yml"
- KINDLE_DATABASE_FILENAME =
"#{KINDLE_SETTINGS_DIRECTORY}/kindle.db"
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #url ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kindle/settings.rb', line 10 def initialize create_default_settings_directory unless Dir.exists?(KINDLE_SETTINGS_DIRECTORY) if File.exists?(KINDLE_SETTINGS_FILENAME) @settings = YAML.load(File.open(KINDLE_SETTINGS_FILENAME).read) || {} settings.each do |name, value| set_variable(name.to_s, value) end else @settings = {} end end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
8 9 10 |
# File 'lib/kindle/settings.rb', line 8 def settings @settings end |
Instance Method Details
#url ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/kindle/settings.rb', line 22 def url if domain.blank? raise "Please set :domain: in your settings file!" else "https://kindle.#{domain}" end end |