Class: SeisRuby::Data::Sac
Overview
Defined Under Namespace
Modules: Ascii, Binary, Body, Head
Instance Attribute Summary collapse
#meta_data, #raw_data
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(raw_data, type = :binary, meta_data = {}) ⇒ Sac
Returns a new instance of Sac.
34
35
36
37
38
|
# File 'lib/seis_ruby/data/sac.rb', line 34
def initialize(raw_data, type = :binary, meta_data = {})
@raw_data = raw_data
@meta_data = meta_data
parse!(type)
end
|
Instance Attribute Details
#body ⇒ Object
41
42
43
|
# File 'lib/seis_ruby/data/sac.rb', line 41
def body
@body
end
|
#head ⇒ Object
40
41
42
|
# File 'lib/seis_ruby/data/sac.rb', line 40
def head
@head
end
|
Class Method Details
.load(raw_data, type = :binary, meta_data = {}) ⇒ Object
16
17
18
|
# File 'lib/seis_ruby/data/sac.rb', line 16
def self.load(raw_data, type = :binary, meta_data = {})
new(raw_data, type, meta_data)
end
|
.load_file(file) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/seis_ruby/data/sac.rb', line 8
def self.load_file(file)
raw_data = File.read_uri(file)
type = type_from_file(file)
meta_data = {file: file}
load(raw_data, type, meta_data)
end
|
.type_from_file(file) ⇒ Object
.uri_for_self?(uri) ⇒ Boolean
Instance Method Details
#==(other) ⇒ Object
70
71
72
73
|
# File 'lib/seis_ruby/data/sac.rb', line 70
def ==(other)
@head == other.head\
&& @body == other.body
end
|
#dump(type = :binary) ⇒ Object
54
55
56
|
# File 'lib/seis_ruby/data/sac.rb', line 54
def dump(type = :binary)
module_from_type(type).dump(@head, @body)
end
|
#dump_file(file) ⇒ Object
47
48
49
50
51
52
|
# File 'lib/seis_ruby/data/sac.rb', line 47
def dump_file(file)
open(file, 'wb'){|io|
io.write(module_from_type(type_from_file(file)).dump(@head, @body))
io.flush
}
end
|
#eql?(other) ⇒ Boolean
58
59
60
61
62
63
64
|
# File 'lib/seis_ruby/data/sac.rb', line 58
def eql?(other)
self.class == other.class\
&& @meta_data.eql?(other.meta_data)\
&& @raw_data.eql?(other.raw_data)\
&& @head.eql?(other.head)\
&& @body.eql?(other.body)
end
|
#hash ⇒ Object
66
67
68
|
# File 'lib/seis_ruby/data/sac.rb', line 66
def hash
[self.class, @meta_data, @raw_data, @head, @body].hash
end
|