class Hypernova::BlankRenderer

Attributes

job[R]

Public Class Methods

new(job) click to toggle source
# File lib/hypernova/blank_renderer.rb, line 4
def initialize(job)
  @job = job
end

Public Instance Methods

render() click to toggle source
# File lib/hypernova/blank_renderer.rb, line 8
  def render
    <<-HTML
      <div data-hypernova-key="#{key}" data-hypernova-id="#{id}"></div>
      <script type="application/json" data-hypernova-key="#{key}" data-hypernova-id="#{id}"><!--#{encode}--></script>
    HTML
  end

Private Instance Methods

data() click to toggle source
# File lib/hypernova/blank_renderer.rb, line 19
def data
  job[:data]
end
encode() click to toggle source
# File lib/hypernova/blank_renderer.rb, line 23
def encode
  JSON.generate(data).gsub(/&/, '&amp;').gsub(/>/, '&gt;')
end
id() click to toggle source
# File lib/hypernova/blank_renderer.rb, line 35
def id
  @id ||= SecureRandom.uuid
end
key() click to toggle source
# File lib/hypernova/blank_renderer.rb, line 27
def key
  name.gsub(/\W/, "")
end
name() click to toggle source
# File lib/hypernova/blank_renderer.rb, line 31
def name
  job[:name]
end