Class: CSSFile
Overview
This class defines a CSS file for subtitles.
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.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vtt2ass/css_file.rb', line 13 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) @rules.push(css_obj) unless css_obj.name.empty? end end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
9 10 11 |
# File 'lib/vtt2ass/css_file.rb', line 9 def rules @rules end |
Instance Method Details
#find_rule(value) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vtt2ass/css_file.rb', line 24 def find_rule(value) return_rule = nil @rules.each do |rule| if rule.name == value return_rule = rule break end end return_rule end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/vtt2ass/css_file.rb', line 35 def to_s @file_path end |