Class: Bicho::Attachment
- Inherits:
-
Object
- Object
- Bicho::Attachment
- Defined in:
- lib/bicho/attachment.rb
Overview
Represents an attachment object for a given bug
Instance Attribute Summary collapse
-
#props ⇒ Object
readonly
Returns the value of attribute props.
Instance Method Summary collapse
-
#bug_id ⇒ Fixnum
Attachment bug id.
-
#content_type ⇒ String
Attachment content type.
-
#data ⇒ StringIO
This will be loaded lazyly every time called.
-
#id ⇒ Fixnum
Attachment id.
-
#initialize(client, xmlrpc_client, props) ⇒ Attachment
constructor
A new instance of Attachment.
-
#size ⇒ Fixnum
Attachment size.
-
#summary ⇒ String
Attachment summary.
Constructor Details
#initialize(client, xmlrpc_client, props) ⇒ Attachment
Returns a new instance of Attachment.
34 35 36 37 38 |
# File 'lib/bicho/attachment.rb', line 34 def initialize(client, xmlrpc_client, props) @client = client @xmlrpc_client = xmlrpc_client @props = props end |
Instance Attribute Details
#props ⇒ Object (readonly)
Returns the value of attribute props.
32 33 34 |
# File 'lib/bicho/attachment.rb', line 32 def props @props end |
Instance Method Details
#bug_id ⇒ Fixnum
Returns attachment bug id.
46 47 48 |
# File 'lib/bicho/attachment.rb', line 46 def bug_id props['bug_id'].to_i end |
#content_type ⇒ String
Returns attachment content type.
51 52 53 |
# File 'lib/bicho/attachment.rb', line 51 def content_type props['content_type'] end |
#data ⇒ StringIO
This will be loaded lazyly every time called
67 68 69 70 71 72 |
# File 'lib/bicho/attachment.rb', line 67 def data ret = @xmlrpc_client.call('Bug.attachments', attachment_ids: [id], include_fields: ['data']) @client.handle_faults(ret) StringIO.new(ret['attachments'][id.to_s]['data']) end |
#id ⇒ Fixnum
Returns attachment id.
41 42 43 |
# File 'lib/bicho/attachment.rb', line 41 def id props['id'].to_i end |
#size ⇒ Fixnum
Returns attachment size.
56 57 58 |
# File 'lib/bicho/attachment.rb', line 56 def size props['size'].to_i end |
#summary ⇒ String
Returns attachment summary.
61 62 63 |
# File 'lib/bicho/attachment.rb', line 61 def summary props['summary'] end |