Class: MMMD::Renderers::PlaintermConstants::StyleManager

Inherits:
Object
  • Object
show all
Defined in:
lib/mmmd/renderers/plainterm.rb

Overview

Class for managing styles and style overrides

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(overrides) ⇒ StyleManager

Returns a new instance of StyleManager.



381
382
383
384
385
# File 'lib/mmmd/renderers/plainterm.rb', line 381

def initialize(overrides)
  @style = self.class.style
  @effect_priority = self.class.effect_priority
  @style = @style.merge(overrides["style"]) if overrides["style"]
end

Instance Attribute Details

#effect_priorityObject (readonly)

Returns the value of attribute effect_priority.



387
388
389
# File 'lib/mmmd/renderers/plainterm.rb', line 387

def effect_priority
  @effect_priority
end

#styleObject (readonly)

Returns the value of attribute style.



387
388
389
# File 'lib/mmmd/renderers/plainterm.rb', line 387

def style
  @style
end

Class Method Details

.define_effect_priority(key, priority) ⇒ void

This method returns an undefined value.

Define an effect priority value

Parameters:

  • key (String)

    effect name

  • priority (Integer)

    value of the priority



363
364
365
366
# File 'lib/mmmd/renderers/plainterm.rb', line 363

def define_effect_priority(key, priority)
  @effect_priority ||= DEFAULT_EFFECT_PRIORITY.dup
  @effect_priority[key] = priority
end

.define_style(key, style) ⇒ void

This method returns an undefined value.

Define a default style for specified class

Parameters:

  • key (String)

    class name

  • style (Hash)

    style



354
355
356
357
# File 'lib/mmmd/renderers/plainterm.rb', line 354

def define_style(key, style)
  @style ||= DEFAULT_STYLE.dup
  @style[key] = style
end

.effect_priorityHash

Get computed effect priority

Returns:

  • (Hash)


376
377
378
# File 'lib/mmmd/renderers/plainterm.rb', line 376

def effect_priority
  @effect_priority ||= DEFAULT_EFFECT_PRIORITY.dup
end

.styleHash

Get computed style

Returns:

  • (Hash)


370
371
372
# File 'lib/mmmd/renderers/plainterm.rb', line 370

def style
  @style ||= DEFAULT_STYLE.dup
end