Class: AnsiChameleon::StyleSheetHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/ansi_chameleon/style_sheet_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(style_sheet_hash, property_name_translator = nil) ⇒ StyleSheetHandler

Returns a new instance of StyleSheetHandler.



4
5
6
7
8
9
10
# File 'lib/ansi_chameleon/style_sheet_handler.rb', line 4

def initialize(style_sheet_hash, property_name_translator=nil)
  @tag_names = []
  @default_values = {}
  @map = {}
  @property_name_translator = property_name_translator
  populate_map(style_sheet_hash)
end

Instance Attribute Details

#default_valuesObject (readonly)

Returns the value of attribute default_values.



12
13
14
# File 'lib/ansi_chameleon/style_sheet_handler.rb', line 12

def default_values
  @default_values
end

#mapObject (readonly)

Returns the value of attribute map.



12
13
14
# File 'lib/ansi_chameleon/style_sheet_handler.rb', line 12

def map
  @map
end

#property_name_translatorObject (readonly)

Returns the value of attribute property_name_translator.



12
13
14
# File 'lib/ansi_chameleon/style_sheet_handler.rb', line 12

def property_name_translator
  @property_name_translator
end

#tag_namesObject (readonly)

Returns the value of attribute tag_names.



12
13
14
# File 'lib/ansi_chameleon/style_sheet_handler.rb', line 12

def tag_names
  @tag_names
end

Instance Method Details

#value_for(*tag_names_chain, property_name) ⇒ Object



14
15
16
17
# File 'lib/ansi_chameleon/style_sheet_handler.rb', line 14

def value_for(*tag_names_chain, property_name)
  strongest = strongest_style_definition(*(tag_names_chain.map { |tag_name| tag_name.to_sym }), property_name.to_sym)
  strongest && strongest[:value]
end