Class: FortranFormatParser::NodeE
- Inherits:
-
Struct
- Object
- Struct
- FortranFormatParser::NodeE
- Defined in:
- ext/fortio/lib/fortio/fortran_format.rb,
ext/fortio/lib/fortio/fortran_format.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#exp ⇒ Object
Returns the value of attribute exp.
-
#length ⇒ Object
Returns the value of attribute length.
-
#prec ⇒ Object
Returns the value of attribute prec.
Instance Method Summary collapse
- #count_args ⇒ Object
- #inspect ⇒ Object
- #read(io, list, state) ⇒ Object
- #write(io, list, state) ⇒ Object
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count
512 513 514 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 512 def count @count end |
#exp ⇒ Object
Returns the value of attribute exp
512 513 514 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 512 def exp @exp end |
#length ⇒ Object
Returns the value of attribute length
512 513 514 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 512 def length @length end |
#prec ⇒ Object
Returns the value of attribute prec
512 513 514 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 512 def prec @prec end |
Instance Method Details
#count_args ⇒ Object
532 533 534 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 532 def count_args return count end |
#inspect ⇒ Object
535 536 537 538 539 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 535 def inspect count_str = count == 1 ? "" : count.to_s exp_str = (exp.nil? or exp == 2) ? "" : "E#{exp}" return "#{count_str}E#{length}.#{prec}#{exp_str}" end |
#read(io, list, state) ⇒ Object
520 521 522 523 524 525 526 527 528 529 530 531 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 520 def read (io, list, state) str = nil count.times do str = io.read(length) if state.zero str = str.gsub(/ /,'0') end list << str.to_f end rescue raise "reading error in fortran format : #{str.dump} for #{self.inspect}" end |
#write(io, list, state) ⇒ Object
514 515 516 517 518 519 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 514 def write (io, list, state) count.times do str = FortranFormat.write_E(state.sign, state.scale, length, prec, exp, list.shift) io << FortranFormat.check_length(length, str) end end |