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.



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

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.



380
381
382
# File 'lib/mmmd/renderers/plainterm.rb', line 380

def effect_priority
  @effect_priority
end

#styleObject (readonly)

Returns the value of attribute style.



380
381
382
# File 'lib/mmmd/renderers/plainterm.rb', line 380

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



356
357
358
359
# File 'lib/mmmd/renderers/plainterm.rb', line 356

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



347
348
349
350
# File 'lib/mmmd/renderers/plainterm.rb', line 347

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

.effect_priorityHash

Get computed effect priority

Returns:

  • (Hash)


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

def effect_priority
  @effect_priority ||= DEFAULT_EFFECT_PRIORITY.dup
end

.styleHash

Get computed style

Returns:

  • (Hash)


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

def style
  @style ||= DEFAULT_STYLE.dup
end