Class: Rpub::Context

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

Instance Method Summary (collapse)

Constructor Details

- (Context) initialize(options = {})

A new instance of Context



5
6
7
8
9
# File 'lib/rpub/context.rb', line 5

def initialize(options = {})
  @config_file = options[:config]
  @layout      = options[:layout]
  @styles      = options[:styles]
end

Instance Method Details

- (Array<String>) chapter_files

All chapter input files loaded into strings. This does not include any of the files listed in the +ignore+ configuration key.

Returns:

  • (Array<String>)


33
34
35
# File 'lib/rpub/context.rb', line 33

def chapter_files
  @chapter_files ||= filter_exceptions(source_files).sort.map(&method(:read))
end

- (Object) config



11
12
13
# File 'lib/rpub/context.rb', line 11

def config
  @config ||= OpenStruct.new(YAML.load_file(config_file) || {})
end

- (Object) fonts



25
26
27
# File 'lib/rpub/context.rb', line 25

def fonts
  @fonts ||= read(styles).scan(/url\((?:'|")?([^'")]+\.[ot]tf)(?:'|")?\)/i).flatten
end

- (String) layout

Path to the current layout file (defaulting to built-in)

Returns:

  • (String)

    path to the current layout file (defaulting to built-in)



16
17
18
# File 'lib/rpub/context.rb', line 16

def layout
  @layout ||= own_or_support_file('layout.html')
end

- (String) styles

Path to the current stylesheet file (defaulting to built-in)

Returns:

  • (String)

    path to the current stylesheet file (defaulting to built-in)



21
22
23
# File 'lib/rpub/context.rb', line 21

def styles
  @styles ||= own_or_support_file('styles.css')
end