Class: Tumblargh::Renderer::Blocks::Audio

Inherits:
Post show all
Defined in:
lib/tumblargh/renderer/blocks/audio.rb

Instance Attribute Summary

Attributes inherited from Tumblargh::Renderer::Base

#context, #node, #options

Instance Method Summary collapse

Methods inherited from Post

#should_render?

Methods inherited from Tumblargh::Renderer::Base

#context_post, contextual_tag, #escape_html, #escape_url, #initialize, #method_missing, #render, #strip_html

Constructor Details

This class inherits a constructor from Tumblargh::Renderer::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tumblargh::Renderer::Base

Instance Method Details

#audio_player(color = :default) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/tumblargh/renderer/blocks/audio.rb', line 6

def audio_player(color=:default)
  html = context.player

  return html if color == :default

  map = { :white => 'FFFFFF', :grey => 'CCCCCC', :black => '000000' }
  color = map[color] unless map[color].nil?

  html.gsub(/color=[A-Z]{6}/i, "color=#{color}")
end

#audio_player_blackObject



25
26
27
# File 'lib/tumblargh/renderer/blocks/audio.rb', line 25

def audio_player_black
  audio_player(:black)
end

#audio_player_greyObject



21
22
23
# File 'lib/tumblargh/renderer/blocks/audio.rb', line 21

def audio_player_grey
  audio_player(:grey)
end

#audio_player_whiteObject



17
18
19
# File 'lib/tumblargh/renderer/blocks/audio.rb', line 17

def audio_player_white
  audio_player(:white)
end

#formatted_play_countObject

TODO



37
38
39
# File 'lib/tumblargh/renderer/blocks/audio.rb', line 37

def formatted_play_count
  play_count.to_s.reverse.scan(/.{1,3}/).join(',').reverse
end

#play_count_with_labelObject



41
42
43
44
# File 'lib/tumblargh/renderer/blocks/audio.rb', line 41

def play_count_with_label
  num = formatted_play_count
  "#{num} play#{num == 1 ? '' : 's'}"
end