Class: SeisRuby::Data::Sac::Ascii

Inherits:
SeisRuby::Data::Sac show all
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'

Instance Attribute Summary

Attributes inherited from SeisRuby::Data::Sac

#body, #head

Attributes inherited from SeisRuby::Data

#meta_data, #raw_data

Class Method Summary collapse

Methods inherited from SeisRuby::Data::Sac

#==, #dump, #dump_file, #eql?, #hash, #initialize, load, load_file, type_from_file

Constructor Details

This class inherits a constructor from SeisRuby::Data::Sac

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