Class: SeisRuby::Data::Cmtsolution::Hypocenter
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- SeisRuby::Data::Cmtsolution::Hypocenter
- Defined in:
- lib/seis_ruby/data/cmtsolution.rb
Constant Summary collapse
- FIELDS =
[ # name, column, converter [:data_source, ( 0..3 ), :strip], [:year, ( 4..8 ), :to_i ], [:month, ( 9..11), :to_i ], [:day, (12..14), :to_i ], [:hour, (15..17), :to_i ], [:minute, (18..20), :to_i ], [:second, (21..26), :to_f ], [:latitude, (27..35), :to_f ], [:longitude, (36..45), :to_f ], [:depth, (46..51), :to_f ], [:mb, (52..55), :to_f ], [:ms, (56..59), :to_f ], [:region_name, (60..-1), :strip], ]
Instance Attribute Summary collapse
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(str) ⇒ Hypocenter
constructor
A new instance of Hypocenter.
-
#origin_time ⇒ Object
Origin time.
Constructor Details
#initialize(str) ⇒ Hypocenter
Returns a new instance of Hypocenter.
50 51 52 53 54 55 56 |
# File 'lib/seis_ruby/data/cmtsolution.rb', line 50 def initialize(str) h = {} FIELDS.each{|name, column, converter| h[name] = str[column].__send__(converter) } super(h) end |
Instance Attribute Details
#table ⇒ Object
Returns the value of attribute table.
57 58 59 |
# File 'lib/seis_ruby/data/cmtsolution.rb', line 57 def table @table end |
Instance Method Details
#origin_time ⇒ Object
Origin time
60 61 62 63 64 65 66 67 68 |
# File 'lib/seis_ruby/data/cmtsolution.rb', line 60 def origin_time sec = self.second int_sec = sec.to_i decimal_sec = sec - int_sec micro_sec = (decimal_sec*(10**6)).round Time.gm( self.year, self.month, self.day, self.hour, self.minute, int_sec, micro_sec) end |