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
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 16 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
29 30 31 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 29 def game raise_abstract_method __method__ end |
#image_local_path ⇒ Pathname
34 35 36 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 34 def image_local_path game.box_large_image.local_path end |
#options_to_s(options) ⇒ String
40 41 42 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 40 def () .map { |o| "#{o}#{OPTION_SEPARATOR}" } end |
#section_to_s(title, content) ⇒ String
47 48 49 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 47 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”.
52 53 54 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 52 def sections raise_abstract_method __method__ end |
#title_icon ⇒ String
57 58 59 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 57 def title_icon raise_abstract_method __method__ end |
#title_to_s(title) ⇒ Object
65 66 67 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 65 def title_to_s(title) "*#{[title_icon, title, title_icon].join(' ')}*" end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb', line 61 def to_s sections.map { |title, content| section_to_s(title, content) }.join(SECTION_SEPARATOR) end |