Class: Minitest::Emoji
- Inherits:
-
Object
- Object
- Minitest::Emoji
- Defined in:
- lib/minitest/emoji_plugin.rb
Constant Summary collapse
- VERSION =
'2.0.0'
Instance Attribute Summary collapse
-
#chars ⇒ Object
readonly
Returns the value of attribute chars.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Class Method Summary collapse
- .add_theme(name, chars) ⇒ Object
- .add_utf_theme(name, p = 0x1f49a, f = 0x1f4a9, e = 0x1f525, s = 0x1f633) ⇒ Object
- .copy_theme(to, from) ⇒ Object
- .emoji! ⇒ Object
- .emoji? ⇒ Boolean
- .show_all_themes ⇒ Object
- .theme ⇒ Object
- .theme!(name) ⇒ Object
- .themes ⇒ Object
Instance Method Summary collapse
-
#initialize(io) ⇒ Emoji
constructor
A new instance of Emoji.
- #method_missing(msg, *args) ⇒ Object
- #print(o) ⇒ Object
Constructor Details
#initialize(io) ⇒ Emoji
Returns a new instance of Emoji.
104 105 106 107 |
# File 'lib/minitest/emoji_plugin.rb', line 104 def initialize io @io = io @chars = self.class.theme end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(msg, *args) ⇒ Object
113 114 115 116 |
# File 'lib/minitest/emoji_plugin.rb', line 113 def method_missing msg, *args return super unless io.respond_to? msg io.send(msg, *args) end |
Instance Attribute Details
#chars ⇒ Object (readonly)
Returns the value of attribute chars.
35 36 37 |
# File 'lib/minitest/emoji_plugin.rb', line 35 def chars @chars end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
35 36 37 |
# File 'lib/minitest/emoji_plugin.rb', line 35 def io @io end |
Class Method Details
.add_theme(name, chars) ⇒ Object
61 62 63 |
# File 'lib/minitest/emoji_plugin.rb', line 61 def self.add_theme name, chars self.themes[name.to_sym] = chars end |
.add_utf_theme(name, p = 0x1f49a, f = 0x1f4a9, e = 0x1f525, s = 0x1f633) ⇒ Object
65 66 67 68 |
# File 'lib/minitest/emoji_plugin.rb', line 65 def self.add_utf_theme name, p=0x1f49a, f=0x1f4a9, e=0x1f525, s=0x1f633 p, f, e, s = [p, f, e, s].pack("U*").chars.map { |c| "#{c} " } add_theme name, "." => p, "E" => e, "F" => f, "S" => s end |
.copy_theme(to, from) ⇒ Object
70 71 72 |
# File 'lib/minitest/emoji_plugin.rb', line 70 def self.copy_theme to, from themes[to] = themes[from] end |
.emoji! ⇒ Object
37 38 39 |
# File 'lib/minitest/emoji_plugin.rb', line 37 def self.emoji! @emoji = true end |
.emoji? ⇒ Boolean
41 42 43 |
# File 'lib/minitest/emoji_plugin.rb', line 41 def self.emoji? @emoji ||= false end |
.show_all_themes ⇒ Object
98 99 100 101 102 |
# File 'lib/minitest/emoji_plugin.rb', line 98 def self.show_all_themes themes.each do |n, c| puts "%10s: %s%s%s%s" % [n, c["."], c["F"], c["E"], c["S"] ] end end |
.theme ⇒ Object
53 54 55 |
# File 'lib/minitest/emoji_plugin.rb', line 53 def self.theme @theme ||= self.themes[:default] end |
.theme!(name) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/minitest/emoji_plugin.rb', line 45 def self.theme! name unless self.themes.include? name.to_sym puts "Theme #{name} not found." exit 1 end @theme ||= self.themes[name.to_sym] end |
.themes ⇒ Object
57 58 59 |
# File 'lib/minitest/emoji_plugin.rb', line 57 def self.themes @themes ||= {} end |
Instance Method Details
#print(o) ⇒ Object
109 110 111 |
# File 'lib/minitest/emoji_plugin.rb', line 109 def print o io.print(chars[o] || o) end |