Class: Telepost::Fake
- Inherits:
-
Object
- Object
- Telepost::Fake
- Defined in:
- lib/telepost.rb
Overview
Note:
Use this class for testing purposes
Fake implementation for testing
Instance Attribute Summary collapse
-
#sent ⇒ Object
readonly
Returns the value of attribute sent.
Instance Method Summary collapse
- #attach(chat, file, caption: nil) ⇒ Object
-
#initialize ⇒ Fake
constructor
A new instance of Fake.
- #post(chat, *lines) ⇒ Object
- #run ⇒ Object
- #spam(*lines) ⇒ Object
Constructor Details
#initialize ⇒ Fake
Returns a new instance of Fake.
30 31 32 |
# File 'lib/telepost.rb', line 30 def initialize @sent = [] end |
Instance Attribute Details
#sent ⇒ Object (readonly)
Returns the value of attribute sent.
28 29 30 |
# File 'lib/telepost.rb', line 28 def sent @sent end |
Instance Method Details
#attach(chat, file, caption: nil) ⇒ Object
44 45 46 47 48 |
# File 'lib/telepost.rb', line 44 def attach(chat, file, caption: nil) path = file.is_a?(String) ? file : file.path tail = caption.nil? ? '' : " caption=#{caption}" @sent << "#{chat}: [attach:#{File.basename(path)}#{tail}]" end |
#post(chat, *lines) ⇒ Object
40 41 42 |
# File 'lib/telepost.rb', line 40 def post(chat, *lines) @sent << "#{chat}: #{lines.join(' ')}" end |
#run ⇒ Object
34 |
# File 'lib/telepost.rb', line 34 def run; end |
#spam(*lines) ⇒ Object
36 37 38 |
# File 'lib/telepost.rb', line 36 def spam(*lines) post(0, lines) end |