Class: Texter::TextPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/texter/text_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, h, options = {}) ⇒ TextPresenter

Returns a new instance of TextPresenter.



8
9
10
11
12
13
14
# File 'app/presenters/texter/text_presenter.rb', line 8

def initialize(text, h, options = {})
  @text    = text
  @h       = h
  @options = options

  options.assert_valid_keys(:locale, :formatter, :formatter_options)
end

Instance Attribute Details

#hObject (readonly)

Returns the value of attribute h.



4
5
6
# File 'app/presenters/texter/text_presenter.rb', line 4

def h
  @h
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'app/presenters/texter/text_presenter.rb', line 4

def options
  @options
end

#textObject (readonly)

Returns the value of attribute text.



4
5
6
# File 'app/presenters/texter/text_presenter.rb', line 4

def text
  @text
end

Instance Method Details

#bodyObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/presenters/texter/text_presenter.rb', line 16

def body
  return formatted unless can_be_edited?

  h.(, formatted, {
    :data => {
      :url => h.texter.edit_text_path(path, :js, :text => {
        :tag_type => tag_type
      })
    },
    :class => "js-edit #{path_for_class}"
  })
end

#path_for_classObject



29
30
31
# File 'app/presenters/texter/text_presenter.rb', line 29

def path_for_class
  path.gsub(/\./, '-')
end