Class: ChupaText::TextData

Inherits:
Data
  • Object
show all
Defined in:
lib/chupa-text/text-data.rb

Instance Attribute Summary

Attributes inherited from Data

#attributes, #body, #expected_screenshot_size, #limit_as, #limit_cpu, #max_body_size, #need_screenshot, #path, #screenshot, #size, #source, #timeout, #uri

Instance Method Summary collapse

Methods inherited from Data

#[], #[]=, #extension, #initialize_copy, #merge!, #mime_type, #mime_type=, #need_screenshot?, #open, #peek_body, #release, #text?, #text_plain?, #to_utf8_body_data

Constructor Details

#initialize(text, options = {}) ⇒ TextData

Returns a new instance of TextData.



19
20
21
22
23
24
25
26
# File 'lib/chupa-text/text-data.rb', line 19

def initialize(text, options={})
  super(options)
  self.uri = uri.to_s.gsub(/\.[a-z\d]+\z/i, ".txt")
  self.path = path.to_s.gsub(/\.[a-z\d]+\z/i, ".txt")
  self.mime_type = "text/plain"
  self.body = text
  self.size = text.bytesize
end