Class: YandexMetrica::Counter
- Inherits:
-
Object
- Object
- YandexMetrica::Counter
- Defined in:
- lib/yandex-metrica/counter.rb
Defined Under Namespace
Classes: Kind, Renderer, TemplateOptions
Instance Attribute Summary collapse
-
#async ⇒ Object
readonly
Returns the value of attribute async.
-
#counter_types ⇒ Object
readonly
Returns the value of attribute counter_types.
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#noscript ⇒ Object
readonly
Returns the value of attribute noscript.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Counter
constructor
A new instance of Counter.
- #to_s ⇒ Object (also: #render)
Constructor Details
#initialize(args = {}) ⇒ Counter
Returns a new instance of Counter.
11 12 13 14 15 16 |
# File 'lib/yandex-metrica/counter.rb', line 11 def initialize(args = {}) @options_types ||= [] (args) append_counter_types(args) @options_renderer = YandexMetrica::Counter::Renderer.new(@options_types) end |
Instance Attribute Details
#async ⇒ Object (readonly)
Returns the value of attribute async.
5 6 7 |
# File 'lib/yandex-metrica/counter.rb', line 5 def async @async end |
#counter_types ⇒ Object (readonly)
Returns the value of attribute counter_types.
5 6 7 |
# File 'lib/yandex-metrica/counter.rb', line 5 def counter_types @counter_types end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
5 6 7 |
# File 'lib/yandex-metrica/counter.rb', line 5 def local @local end |
#noscript ⇒ Object (readonly)
Returns the value of attribute noscript.
5 6 7 |
# File 'lib/yandex-metrica/counter.rb', line 5 def noscript @noscript end |
Instance Method Details
#to_s ⇒ Object Also known as: render
18 19 20 21 22 23 |
# File 'lib/yandex-metrica/counter.rb', line 18 def to_s return if YM.invalid_counter? template_name = @async ? "async" : "sync" @template ||= ::ERB.new ::File.read ::File.("../templates/#{template_name}.erb", __FILE__) @template.result(.instance_eval { binding }).html_safe end |