Class: Fasti::StyleParser
- Inherits:
-
Object
- Object
- Fasti::StyleParser
- Defined in:
- lib/fasti/style_parser.rb
Overview
Parses style definition strings into Style objects for calendar formatting.
This class handles the parsing of style definition strings in the format: “target:attribute=value,attribute,no-attribute target:attribute=value”
Supported targets:
-
Weekdays: sunday, monday, tuesday, wednesday, thursday, friday, saturday
-
Special days: holiday, today
Supported attributes:
-
Colors: foreground=color, background=color
-
Text effects: bold, italic, underline, underline=double, overline, blink, inverse, hide, faint
-
Negation: no-bold, no-italic, etc.
Instance Method Summary collapse
-
#parse(style_string) ⇒ Hash<Symbol, Style>
Parses a style definition string into a hash of Style objects.
Instance Method Details
#parse(style_string) ⇒ Hash<Symbol, Style>
Parses a style definition string into a hash of Style objects.
52 53 54 55 56 57 58 59 |
# File 'lib/fasti/style_parser.rb', line 52 def parse(style_string) return {} if style_string.nil? || style_string.strip.empty? style_string.strip.split(/\s+/).each_with_object({}) do |entry, styles| target, attributes_hash = parse_entry(entry) styles[target] = create_style(attributes_hash) end end |