Class: Styles::Stylesheet
- Inherits:
-
Object
- Object
- Styles::Stylesheet
- Defined in:
- lib/styles/stylesheet.rb
Defined Under Namespace
Classes: EvalContext
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#last_updated ⇒ Object
readonly
Returns the value of attribute last_updated.
-
#rules ⇒ Object
Returns the value of attribute rules.
Class Method Summary collapse
-
.from_string(string) ⇒ Object
For creating a one off, temporary Stylesheet without an associated file.
Instance Method Summary collapse
-
#initialize(stylesheet_file_path = nil) ⇒ Stylesheet
constructor
A new instance of Stylesheet.
- #outdated? ⇒ Boolean
- #reload ⇒ Object
- #reload_if_outdated ⇒ Object
- #unrecognized_property_names ⇒ Object
Constructor Details
#initialize(stylesheet_file_path = nil) ⇒ Stylesheet
Returns a new instance of Stylesheet.
15 16 17 18 19 20 |
# File 'lib/styles/stylesheet.rb', line 15 def initialize(stylesheet_file_path=nil) @file_path = stylesheet_file_path @rules = [] @last_updated = nil load_rules_from_file if @file_path end |
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
4 5 6 |
# File 'lib/styles/stylesheet.rb', line 4 def file_path @file_path end |
#last_updated ⇒ Object
Returns the value of attribute last_updated.
5 6 7 |
# File 'lib/styles/stylesheet.rb', line 5 def last_updated @last_updated end |
#rules ⇒ Object
Returns the value of attribute rules.
4 5 6 |
# File 'lib/styles/stylesheet.rb', line 4 def rules @rules end |
Class Method Details
.from_string(string) ⇒ Object
For creating a one off, temporary Stylesheet without an associated file. Mostly useful for testing.
9 10 11 12 13 |
# File 'lib/styles/stylesheet.rb', line 9 def self.from_string(string) stylesheet = new stylesheet.rules = eval_rules string stylesheet end |
Instance Method Details
#outdated? ⇒ Boolean
30 31 32 |
# File 'lib/styles/stylesheet.rb', line 30 def outdated? !last_updated || file_mtime > last_updated end |
#reload ⇒ Object
26 27 28 |
# File 'lib/styles/stylesheet.rb', line 26 def reload load_rules_from_file end |
#reload_if_outdated ⇒ Object
34 35 36 |
# File 'lib/styles/stylesheet.rb', line 34 def reload_if_outdated reload if outdated? end |
#unrecognized_property_names ⇒ Object
22 23 24 |
# File 'lib/styles/stylesheet.rb', line 22 def unrecognized_property_names rules.map { |rule| rule.unrecognized_properties.keys }.flatten end |