Class: Bicho::Attachment

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

Overview

Represents an attachment object for a given bug

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#propsObject (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_idFixnum

Returns attachment bug id.

Returns:

  • (Fixnum)

    attachment bug id



46
47
48
# File 'lib/bicho/attachment.rb', line 46

def bug_id
  props['bug_id'].to_i
end

#content_typeString

Returns attachment content type.

Returns:

  • (String)

    attachment content type



51
52
53
# File 'lib/bicho/attachment.rb', line 51

def content_type
  props['content_type']
end

#dataStringIO

This will be loaded lazyly every time called

Returns:

  • (StringIO)

    attachmentdata



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

#idFixnum

Returns attachment id.

Returns:

  • (Fixnum)

    attachment id



41
42
43
# File 'lib/bicho/attachment.rb', line 41

def id
  props['id'].to_i
end

#sizeFixnum

Returns attachment size.

Returns:

  • (Fixnum)

    attachment size



56
57
58
# File 'lib/bicho/attachment.rb', line 56

def size
  props['size'].to_i
end

#summaryString

Returns attachment summary.

Returns:

  • (String)

    attachment summary



61
62
63
# File 'lib/bicho/attachment.rb', line 61

def summary
  props['summary']
end