class Stylesheet
A presentation stylesheet loaded beside slides.
Root style.css is global. Nested style.css files apply to slides below
their directory, while a CSS file matching a slide name applies only to
that slide.
Nested Classes and Modules
Definitions
def initialize(root, path, scope = nil)
Initialize a stylesheet.
Signature
-
parameter
rootString The presentation slides root.
-
parameter
pathString The path relative to the slides root.
-
parameter
scopeString | Nil The CSS scope selector, or nil for global CSS.
Implementation
def initialize(root, path, scope = nil)
@root = File.expand_path(root)
@path = path
@scope = scope
end
attr :path
Signature
-
attribute
String The path relative to the presentation root.
attr :scope
Signature
-
attribute
String | Nil The generated CSS scope selector.
def url
The URL from which this stylesheet is served.
Signature
-
returns
String
Implementation
def url
PREFIX + self.class.encode_path(@path)
end
def source_path
The absolute source path.
Signature
-
returns
String
Implementation
def source_path
File.join(@root, @path)
end
def read
Read this stylesheet and apply its generated scope when required.
Signature
-
returns
String
Implementation
def read
content = File.read(source_path)
return content unless @scope
"@scope (#{@scope}) {\n#{content}\n}\n"
end