Class: Rpub::Context
- Inherits:
-
Object
- Object
- Rpub::Context
- Defined in:
- lib/rpub/context.rb
Instance Method Summary collapse
-
#chapter_files ⇒ Array<String>
All chapter input files loaded into strings.
- #config ⇒ Object
- #fonts ⇒ Object
-
#initialize(options = {}) ⇒ Context
constructor
A new instance of Context.
-
#layout ⇒ String
Path to the current layout file (defaulting to built-in).
-
#styles ⇒ String
Path to the current stylesheet file (defaulting to built-in).
Constructor Details
#initialize(options = {}) ⇒ Context
Returns a new instance of Context.
5 6 7 8 9 |
# File 'lib/rpub/context.rb', line 5 def initialize( = {}) @config_file = [:config] @layout = [:layout] @styles = [:styles] end |
Instance Method Details
#chapter_files ⇒ Array<String>
All chapter input files loaded into strings. This does not include any of the files listed in the +ignore+ configuration key.
33 34 35 |
# File 'lib/rpub/context.rb', line 33 def chapter_files @chapter_files ||= filter_exceptions(source_files).sort.map(&method(:read)) end |
#config ⇒ Object
11 12 13 |
# File 'lib/rpub/context.rb', line 11 def config @config ||= OpenStruct.new(YAML.load_file(config_file) || {}) end |
#fonts ⇒ Object
25 26 27 |
# File 'lib/rpub/context.rb', line 25 def fonts @fonts ||= read(styles).scan(/url\((?:'|")?([^'")]+\.[ot]tf)(?:'|")?\)/i).flatten end |
#layout ⇒ String
Returns 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 |
#styles ⇒ String
Returns 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 |