Class: SilkLayout::CSS::ComputedStyle

Inherits:
Object
  • Object
show all
Defined in:
lib/silk_layout/css/computed_style.rb

Instance Method Summary collapse

Constructor Details

#initialize(rules, parent_style = nil) ⇒ ComputedStyle

Returns a new instance of ComputedStyle.



6
7
8
9
10
11
12
13
14
# File 'lib/silk_layout/css/computed_style.rb', line 6

def initialize(rules, parent_style = nil)
  @values = {}
  @explicit_properties = {}

  apply_rules(rules)

  apply_inheritance(parent_style)
  apply_defaults
end

Instance Method Details

#[](property) ⇒ Object



16
17
18
# File 'lib/silk_layout/css/computed_style.rb', line 16

def [](property)
  @values[property]
end

#explicit_display?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/silk_layout/css/computed_style.rb', line 34

def explicit_display?
  @explicit_properties.key?("display")
end

#explicit_height?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/silk_layout/css/computed_style.rb', line 29

def explicit_height?
  value = @values["height"]
  value && value != "auto"
end

#explicit_width?Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/silk_layout/css/computed_style.rb', line 24

def explicit_width?
  value = @values["width"]
  value && value != "auto"
end

#widthObject



20
21
22
# File 'lib/silk_layout/css/computed_style.rb', line 20

def width
  @values["width"]
end