class Rightmove::Archive
Attributes
branch_id[RW]
document[RW]
timestamp[RW]
zip_file[RW]
Public Class Methods
new(file = nil)
click to toggle source
# File lib/rightmove.rb, line 8 def initialize(file = nil) open(file) unless file.nil? end
Public Instance Methods
open(file)
click to toggle source
# File lib/rightmove.rb, line 12 def open(file) self.zip_file = file read end
zip_file=(file)
click to toggle source
# File lib/rightmove.rb, line 17 def zip_file=(file) if file.instance_of?(Zip::ZipFile) @zip_file = file else return false unless File.exists?(file) @zip_file = Zip::ZipFile.open(file) end parse_file_name end
Private Instance Methods
parse_file_name()
click to toggle source
# File lib/rightmove.rb, line 33 def parse_file_name branch_id, timestamp = @zip_file.to_s.split("_").pop(2) @branch_id = branch_id.to_i @timestamp = time_from_string(timestamp) end
read()
click to toggle source
# File lib/rightmove.rb, line 28 def read blm = self.zip_file.entries.select {|v| v.to_s =~ /\.blm/i }.first @document = BLM::Document.new( self.zip_file.read(blm) ) end
time_from_string(string)
click to toggle source
# File lib/rightmove.rb, line 39 def time_from_string(string) nums = string.split("").map(&:to_i) take = lambda { |nums, i| nums.shift(i).join.to_i } Time.new(take.call(nums, 4), take.call(nums, 2), take.call(nums, 2), take.call(nums, 2), take.call(nums, 2), take.call(nums, 2)) end