Class: Makimono::Style

Inherits:
Resource show all
Defined in:
lib/makimono/style.rb

Constant Summary collapse

PRESETS =
%w[fuji fuji_tategaki].freeze

Constants inherited from Resource

Resource::ORDERED_BASENAME_REGEXP

Instance Attribute Summary

Attributes inherited from Resource

#content, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#basename, #basename=, #dirname, #extname, #extname=, #initialize, #number, #ordered?, #title

Constructor Details

This class inherits a constructor from Makimono::Resource

Class Method Details

.from_style_config(style_config) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/makimono/style.rb', line 9

def self.from_style_config(style_config)
  path = if PRESETS.include?(style_config)
           File.expand_path("../styles/#{style_config}.css", __dir__)
         elsif File.file?(style_config.to_s)
           File.expand_path(style_config.to_s)
         else
           raise InvalidStyleError, "Style file `#{style_config}` does not exist"
         end

  new(File.basename(path), File.read(path))
end

Instance Method Details

#relative_path_from(dir) ⇒ Object



21
22
23
# File 'lib/makimono/style.rb', line 21

def relative_path_from(dir)
  Pathname.new(path).relative_path_from(dir)
end