Module: SeisRuby::Data::Sac::Ascii

Defined in:
lib/seis_ruby/data/sac/ascii.rb

Defined Under Namespace

Modules: Head

Constant Summary collapse

EXT =
'.sac_ascii'
DATA_COLUMN_SIZE =
5
DATA_FORMAT_STRING =
'%#15.7g'

Class Method Summary collapse

Class Method Details

.dump(head, body) ⇒ Object



21
22
23
24
# File 'lib/seis_ruby/data/sac/ascii.rb', line 21

def dump(head, body)
  ::SeisRuby::Data::Sac::Ascii::Head.convert_to_head_str(head)\
  + format_body(::SeisRuby::Data::Sac::Body.body_for_dump(body, head))
end

.parse(str) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/seis_ruby/data/sac/ascii.rb', line 10

def parse(str)
  head_str, body_str = separate_head_body(str)

  head = ::SeisRuby::Data::Sac::Ascii::Head\
    .convert_from_head_str(head_str)
  body = ::SeisRuby::Data::Sac::Body\
    .shape_body(body_str.split.map(&:to_f), head)

  [head, body]
end

.uri_for_self?(uri) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/seis_ruby/data/sac/ascii.rb', line 26

def uri_for_self?(uri)
  uri =~ /#{Regexp.escape(EXT)}\z/i
end