Class: Md2key::Configuration

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(masters: []) ⇒ Configuration

Returns a new instance of Configuration.



39
40
41
42
# File 'lib/md2key/configuration.rb', line 39

def initialize(masters: [])
  @masters = masters
  validate!
end

Class Method Details

.loadObject



6
7
8
9
10
11
# File 'lib/md2key/configuration.rb', line 6

def load
  config = {}
  config.merge!(load_if_available(File.expand_path('~/.md2key')))
  config.merge!(load_if_available(File.expand_path('./.md2key')))
  new(symbolize_keys(config))
end

Instance Method Details

#cover_masterObject



44
45
46
47
48
49
# File 'lib/md2key/configuration.rb', line 44

def cover_master
  master = @masters.find do |master|
    master[:cover]
  end
  master && master[:name]
end

#slide_master(level) ⇒ Object



51
52
53
54
55
56
# File 'lib/md2key/configuration.rb', line 51

def slide_master(level)
  master = @masters.find do |master|
    master[:template] == level
  end
  master && master[:name]
end