Class: Archaeo::WarcRecord

Inherits:
Struct
  • Object
show all
Defined in:
lib/archaeo/warc_support.rb

Overview

Value object representing a single WARC record.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



213
214
215
# File 'lib/archaeo/warc_support.rb', line 213

def body
  @body
end

#headersObject

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



213
214
215
# File 'lib/archaeo/warc_support.rb', line 213

def headers
  @headers
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



213
214
215
# File 'lib/archaeo/warc_support.rb', line 213

def version
  @version
end

Instance Method Details

#content_lengthObject



233
234
235
# File 'lib/archaeo/warc_support.rb', line 233

def content_length
  headers[:content_length].to_i
end

#content_typeObject



229
230
231
# File 'lib/archaeo/warc_support.rb', line 229

def content_type
  headers[:content_type]
end

#dateObject



225
226
227
# File 'lib/archaeo/warc_support.rb', line 225

def date
  headers[:warc_date]
end

#response?Boolean

Returns:

  • (Boolean)


237
238
239
# File 'lib/archaeo/warc_support.rb', line 237

def response?
  warc_type == "response"
end

#target_uriObject



221
222
223
# File 'lib/archaeo/warc_support.rb', line 221

def target_uri
  headers[:warc_target_uri]
end

#to_hObject



245
246
247
# File 'lib/archaeo/warc_support.rb', line 245

def to_h
  { version: version, headers: headers, body_length: body.to_s.bytesize }
end

#warc_typeObject



217
218
219
# File 'lib/archaeo/warc_support.rb', line 217

def warc_type
  headers[:warc_type]
end

#warcinfo?Boolean

Returns:

  • (Boolean)


241
242
243
# File 'lib/archaeo/warc_support.rb', line 241

def warcinfo?
  warc_type == "warcinfo"
end