Class: CSSRule
- Inherits:
-
Object
- Object
- CSSRule
- Defined in:
- lib/vtt2ass/css_rule.rb
Overview
This class defines a CSS rule that is included in the CSS file.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#initialize(selector, declarations) ⇒ CSSRule
constructor
A new instance of CSSRule.
-
#reduce_selector(selector) ⇒ Object
This method removes the generic selector from a block.
- #to_s ⇒ Object
Constructor Details
#initialize(selector, declarations) ⇒ CSSRule
Returns a new instance of CSSRule.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/vtt2ass/css_rule.rb', line 8 def initialize(selector, declarations) @name = reduce_selector(selector) @properties = [] declarations.split(/;\s?/).each do |dec| temp = dec.split(/:\s?/) @properties.push( { key: temp.first, value: temp.last } ) end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/vtt2ass/css_rule.rb', line 6 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
6 7 8 |
# File 'lib/vtt2ass/css_rule.rb', line 6 def properties @properties end |
Instance Method Details
#reduce_selector(selector) ⇒ Object
This method removes the generic selector from a block.
25 26 27 28 29 |
# File 'lib/vtt2ass/css_rule.rb', line 25 def reduce_selector(selector) selector.to_s.gsub( /\.rmp-container>\.rmp-content>\.rmp-cc-area>\.rmp-cc-container>\.rmp-cc-display>\.rmp-cc-cue\s?\.?/, '' ) end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/vtt2ass/css_rule.rb', line 19 def to_s "#{@name} #{@properties}" end |