Class: CSSFile
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #find_rule(value) ⇒ Object
-
#initialize(file_path) ⇒ CSSFile
constructor
A new instance of CSSFile.
- #to_s ⇒ Object
Constructor Details
#initialize(file_path) ⇒ CSSFile
Returns a new instance of CSSFile.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/vtt2ass/css_file.rb', line 8 def initialize(file_path) @file_path = file_path parser = CssParser::Parser.new parser.load_file!(file_path) @rules = [] parser.each_selector do |selector, declarations, specificity| css_obj = CSSRule.new(selector, declarations) if not css_obj.name.empty? then @rules.push(css_obj) end end end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
5 6 7 |
# File 'lib/vtt2ass/css_file.rb', line 5 def rules @rules end |
Instance Method Details
#find_rule(value) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vtt2ass/css_file.rb', line 21 def find_rule(value) return_rule = nil @rules.each do |rule| if rule.name == value then return_rule = rule break end end return return_rule end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/vtt2ass/css_file.rb', line 32 def to_s return @file_path end |