Class: Titlezilla::Translator

Inherits:
Object
  • Object
show all
Defined in:
lib/titlezilla/translator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller_path, action_name, context = {}) ⇒ Translator

Returns a new instance of Translator.



7
8
9
10
11
# File 'lib/titlezilla/translator.rb', line 7

def initialize(controller_path, action_name, context = {})
  @namespace, @controller_name = parse_namespace_and_controller_name(controller_path)
  @action_name = action_name.to_s.freeze
  @context = context
end

Instance Attribute Details

#action_nameObject (readonly)

Returns the value of attribute action_name.



5
6
7
# File 'lib/titlezilla/translator.rb', line 5

def action_name
  @action_name
end

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/titlezilla/translator.rb', line 5

def context
  @context
end

#controller_nameObject (readonly)

Returns the value of attribute controller_name.



5
6
7
# File 'lib/titlezilla/translator.rb', line 5

def controller_name
  @controller_name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



5
6
7
# File 'lib/titlezilla/translator.rb', line 5

def namespace
  @namespace
end

Instance Method Details

#application_titleObject



17
18
19
# File 'lib/titlezilla/translator.rb', line 17

def application_title
  lookup('application')
end

#meta_titleObject



21
22
23
# File 'lib/titlezilla/translator.rb', line 21

def meta_title
  [title, application_title].compact.join(::Titlezilla.configuration.separator)
end

#titleObject



13
14
15
# File 'lib/titlezilla/translator.rb', line 13

def title
  lookup(controller_name, map(action_name))
end