Class: Fuse::Document::Asset::StyleSheet::Conditional
- Inherits:
-
Object
- Object
- Fuse::Document::Asset::StyleSheet::Conditional
- Defined in:
- lib/fuse/document/asset/style_sheet.rb
Constant Summary collapse
- CONDITIONAL_PATTERN =
/\((!|[lg]te?\s+)?ie(\s*\d+)?\)(?:\.[a-z]+$|\s*\()/i
Instance Attribute Summary collapse
-
#comparison ⇒ Object
readonly
Returns the value of attribute comparison.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(style_sheet) ⇒ Conditional
constructor
A new instance of Conditional.
- #signature ⇒ Object
- #wrap(content) ⇒ Object
Constructor Details
#initialize(style_sheet) ⇒ Conditional
Returns a new instance of Conditional.
57 58 59 60 61 62 |
# File 'lib/fuse/document/asset/style_sheet.rb', line 57 def initialize(style_sheet) match = CONDITIONAL_PATTERN.match(style_sheet.path) return unless match @comparison = (match[1] || '').strip.downcase @version = match[2].strip.to_i unless match[2].nil? end |
Instance Attribute Details
#comparison ⇒ Object (readonly)
Returns the value of attribute comparison.
55 56 57 |
# File 'lib/fuse/document/asset/style_sheet.rb', line 55 def comparison @comparison end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
55 56 57 |
# File 'lib/fuse/document/asset/style_sheet.rb', line 55 def version @version end |
Instance Method Details
#signature ⇒ Object
74 75 76 77 78 79 |
# File 'lib/fuse/document/asset/style_sheet.rb', line 74 def signature @signature ||= begin ret = (comparison.nil? || comparison.empty?) ? 'IE' : comparison + ' IE' ret << ' ' + version.to_s if version end end |
#wrap(content) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/fuse/document/asset/style_sheet.rb', line 64 def wrap(content) if comparison == '!' "<!--[if !IE]> -->#{content}<!-- <![endif]-->" elsif comparison "<!--[if #{signature}]>#{content}<![endif]-->" else content end end |