Class: Fiddler::Attachment

Inherits:
Object
  • Object
show all
Includes:
ActiveAttr::Model
Defined in:
lib/fiddler/attachment.rb

Overview

the attachment in itself

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



50
51
52
# File 'lib/fiddler/attachment.rb', line 50

def content
  @content
end

#pathObject

Returns the value of attribute path.



50
51
52
# File 'lib/fiddler/attachment.rb', line 50

def path
  @path
end

#ticket_idObject

Returns the value of attribute ticket_id.



50
51
52
# File 'lib/fiddler/attachment.rb', line 50

def ticket_id
  @ticket_id
end

Class Method Details

.get(id, ticket_id) ⇒ Object

Public class method to get an attachment



53
54
55
56
57
58
59
# File 'lib/fiddler/attachment.rb', line 53

def self.get(id, ticket_id)
   url = "/ticket/#{ticket_id}/attachments/#{id}"
   response = Fiddler::ConnectionManager.get(url)
   attachment = Fiddler::Parsers::AttachmentParser.parse_single(response)
   attachment.ticket_id = ticket_id
   attachment
end

Instance Method Details

#content_lengthObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/fiddler/attachment.rb', line 61

def content_length
   length = header_value_for_key("Content-Length")
   if !length.nil?
      length.to_i
   elsif @content.nil?
      -1
   else
      @content.length
   end
end

#has_text_contentObject



82
83
84
85
86
87
88
# File 'lib/fiddler/attachment.rb', line 82

def has_text_content
   if content_type == "text/plain" or content_type == "text/html"
      return true
   else
      return false
   end
end