Class: ConditionalMessages::ReadCategory

Inherits:
Object
  • Object
show all
Defined in:
lib/conditional_messages/read_category.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(category) ⇒ ReadCategory

Returns a new instance of ReadCategory.



12
13
14
# File 'lib/conditional_messages/read_category.rb', line 12

def initialize(category)
  @category = category
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



10
11
12
# File 'lib/conditional_messages/read_category.rb', line 10

def category
  @category
end

Instance Method Details

#for(context) ⇒ Object



20
21
22
23
24
# File 'lib/conditional_messages/read_category.rb', line 20

def for(context)
  context_holder = ContextHolder.new(context)
  applied_message = FindMessage.for(context_holder, category)
  ReadMessage.new(context, applied_message, renderer.new)
end

#nameObject



16
17
18
# File 'lib/conditional_messages/read_category.rb', line 16

def name
  category.name
end

#rendererObject



26
27
28
29
30
31
32
# File 'lib/conditional_messages/read_category.rb', line 26

def renderer
  if defined?(Redcarpet) && defined?(Nokogiri)
    HTMLRenderer
  else
    TextRenderer
  end
end