Module: RubyTypistHelper

Included in:
RubyTypist::Typist
Defined in:
app/helpers/ruby_typist_helper.rb

Instance Method Summary collapse

Instance Method Details

#typer(typer_content) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/ruby_typist_helper.rb', line 2

def typer(typer_content)
  return unless valid_typer_content?(typer_content)

  answer = "["
  typer_content.each_with_index do |value, index|
    answer += index != typer_content.count - 1 ? "\"#{value}\"," : "\"#{value}\""
  end
  answer += "]"

  html_content = "<span id='ruby-typist' data-period='2000' data-typer='#{answer}'>#{typer_content[0]}</span>"
  insert_js html_content
end