Module: EhbrsRubyUtils::Bga::WhatsappFormatter
- Defined in:
- lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb,
lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb
Defined Under Namespace
Classes: Option
Constant Summary collapse
- LINE_SEPARATOR =
"\n"
- OPTION_SEPARATOR =
LINE_SEPARATOR
- SECTION_SEPARATOR =
"#{LINE_SEPARATOR}#{LINE_SEPARATOR}"
Instance Method Summary collapse
- #content_to_s(content) ⇒ String
- #game ⇒ EhbrsRubyUtils::Bga::Game
- #image_local_path ⇒ Pathname
- #options_to_s(options) ⇒ String
- #section_to_s(title, content) ⇒ String
-
#sections ⇒ Hash<String, String>
“title” => “content”.
- #title_icon ⇒ String
- #title_to_s(title) ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#content_to_s(content) ⇒ String
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 18 def content_to_s(content) if content.is_a?(::Hash) content_to_s( content.map { |k, v| ::EhbrsRubyUtils::Bga::WhatsappFormatter::Option.new(k, v) } ) elsif content.is_a?(::Enumerable) content.to_a.join(OPTION_SEPARATOR) else content.to_s end end |
#game ⇒ EhbrsRubyUtils::Bga::Game
31 32 33 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 31 def game raise_abstract_method __method__ end |
#image_local_path ⇒ Pathname
36 37 38 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 36 def image_local_path game.box_large_image.local_path end |
#options_to_s(options) ⇒ String
42 43 44 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 42 def () .map { |o| "#{o}#{OPTION_SEPARATOR}" } end |
#section_to_s(title, content) ⇒ String
49 50 51 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 49 def section_to_s(title, content) [title_to_s(title), content_to_s(content)].map(&:strip).join(SECTION_SEPARATOR) end |
#sections ⇒ Hash<String, String>
Returns “title” => “content”.
54 55 56 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 54 def sections raise_abstract_method __method__ end |
#title_icon ⇒ String
59 60 61 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 59 def title_icon raise_abstract_method __method__ end |
#title_to_s(title) ⇒ Object
67 68 69 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 67 def title_to_s(title) "*#{[title_icon, title, title_icon].join(' ')}*" end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 63 def to_s sections.map { |title, content| section_to_s(title, content) }.join(SECTION_SEPARATOR) end |