Class: Telepost::Fake

Inherits:
Object
  • Object
show all
Defined in:
lib/telepost.rb

Overview

Note:

Use this class for testing purposes

Fake implementation for testing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFake

Returns a new instance of Fake.



30
31
32
# File 'lib/telepost.rb', line 30

def initialize
  @sent = []
end

Instance Attribute Details

#sentObject (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



46
47
48
49
50
# File 'lib/telepost.rb', line 46

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



42
43
44
# File 'lib/telepost.rb', line 42

def post(chat, *lines)
  @sent << "#{chat}: #{lines.join(' ')}"
end

#runObject



34
35
36
# File 'lib/telepost.rb', line 34

def run
  # Nothing to do here
end

#spam(*lines) ⇒ Object



38
39
40
# File 'lib/telepost.rb', line 38

def spam(*lines)
  post(0, lines)
end