Class: ContributorsStats::Formatter::Html

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/contributors_stats/formatter/html.rb

Overview

generate html for a contributor, by default it will create a link to profile with contributor avatar

Constant Summary collapse

DEFAULT_TEMPLATE =

default template building link to profile with contributor avatar

%q{%Q{<a href="#{data['html_url']}" title="#{login} - #{data['contributions']}"><img src="#{data['avatar_url']}" alt="#{login} - #{data['contributions']}"/></a>}}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Html

create the generator object

Parameters:

  • template (Hash)

    a customizable set of options



13
14
15
# File 'lib/plugins/contributors_stats/formatter/html.rb', line 13

def initialize(options = {})
  @template = options[:template] || DEFAULT_TEMPLATE
end

Instance Attribute Details

#templateObject

access to the template used to generate content



9
10
11
# File 'lib/plugins/contributors_stats/formatter/html.rb', line 9

def template
  @template
end

Instance Method Details

#format(login, data) ⇒ String

format user data using template

Parameters:

  • login (String)

    user name

  • data (Hash)

    user data

Returns:

  • (String)


21
22
23
# File 'lib/plugins/contributors_stats/formatter/html.rb', line 21

def format(, data)
  eval(template)
end