Class: JekyllEBook::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-e-book/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Config

Returns a new instance of Config.



7
8
9
# File 'lib/jekyll-e-book/config.rb', line 7

def initialize(config)
  @config = config
end

Instance Method Details

#creatorObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/jekyll-e-book/config.rb', line 43

def creator
  case
  when !ebook['creator'].nil?
    ebook['creator']
  when site['author'].is_a?(String)
    site['author']
  when site['author'].is_a?(Hash) && !site['author']['name'].nil?
    site['author']['name']
  else
    nil
  end
end

#dateObject



39
40
41
# File 'lib/jekyll-e-book/config.rb', line 39

def date
  ebook['date'] || Time.now
end

#destinationObject



19
20
21
# File 'lib/jekyll-e-book/config.rb', line 19

def destination
  File.expand_path(ebook['destination'] || '_ebook')
end

#file_nameObject



23
24
25
# File 'lib/jekyll-e-book/config.rb', line 23

def file_name
  "#{ebook['file_name'] || title}.epub"
end

#identifierObject



27
28
29
# File 'lib/jekyll-e-book/config.rb', line 27

def identifier
  ebook['identifier'] || site['url'].nil? ? nil : "#{site['url']}#{site['base_url']}" || SecureRandom.uuid
end

#languageObject



35
36
37
# File 'lib/jekyll-e-book/config.rb', line 35

def language
  ebook['language'] || site['language'] || site['lang'] or raise InvalidConfigError, 'Language is required'
end

#layoutObject



15
16
17
# File 'lib/jekyll-e-book/config.rb', line 15

def layout
  ebook['layout']
end

#page_progression_directionObject



56
57
58
# File 'lib/jekyll-e-book/config.rb', line 56

def page_progression_direction
  ebook['page_progression_direction']
end

#skip_build?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/jekyll-e-book/config.rb', line 11

def skip_build?
  ebook['build'] == 'false'
end

#titleObject



31
32
33
# File 'lib/jekyll-e-book/config.rb', line 31

def title
  ebook['title'] || site['title'] or raise InvalidConfigError, 'Title is required'
end