Class: Netbout::Bout
- Inherits:
-
Object
- Object
- Netbout::Bout
- Defined in:
- lib/netbout/bout.rb
Overview
Bout.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(iri, token, json) ⇒ Bout
constructor
A new instance of Bout.
- #owner ⇒ Object
- #post(text) ⇒ Object
- #tags ⇒ Object
- #take(id) ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(iri, token, json) ⇒ Bout
Returns a new instance of Bout.
33 34 35 36 37 |
# File 'lib/netbout/bout.rb', line 33 def initialize(iri, token, json) @iri = iri @token = token @json = json end |
Instance Method Details
#id ⇒ Object
39 40 41 |
# File 'lib/netbout/bout.rb', line 39 def id @json['id'] end |
#owner ⇒ Object
47 48 49 |
# File 'lib/netbout/bout.rb', line 47 def owner @json['owner'] end |
#post(text) ⇒ Object
51 52 53 54 55 |
# File 'lib/netbout/bout.rb', line 51 def post(text) rsp = Netbout::Http.new(@iri.append('/b').append(id).append('/post'), @token).post('text' => text) id = rsp.headers['X-Netbout-Message'].to_i take(id) end |
#tags ⇒ Object
62 63 64 |
# File 'lib/netbout/bout.rb', line 62 def Netbout::Tags.new(@iri, @token, id) end |
#take(id) ⇒ Object
57 58 59 60 |
# File 'lib/netbout/bout.rb', line 57 def take(id) rsp = Netbout::Http.new(@iri.append('/message').append(id), @token).get Netbout::Message.new(@iri, @token, JSON.parse(rsp.response_body)) end |
#title ⇒ Object
43 44 45 |
# File 'lib/netbout/bout.rb', line 43 def title @json['title'] end |