Class: FortranFormatParser::NodeG
- Inherits:
-
Struct
- Object
- Struct
- FortranFormatParser::NodeG
- 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
572 573 574 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 572 def count @count end |
#exp ⇒ Object
Returns the value of attribute exp
572 573 574 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 572 def exp @exp end |
#length ⇒ Object
Returns the value of attribute length
572 573 574 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 572 def length @length end |
#prec ⇒ Object
Returns the value of attribute prec
572 573 574 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 572 def prec @prec end |
Instance Method Details
#count_args ⇒ Object
592 593 594 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 592 def count_args return count end |
#inspect ⇒ Object
595 596 597 598 599 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 595 def inspect count_str = count == 1 ? "" : count.to_s exp_str = (exp.nil? or exp == 2) ? "" : "E#{exp}" return "#{count_str}G#{length}.#{prec}#{exp_str}" end |
#read(io, list, state) ⇒ Object
580 581 582 583 584 585 586 587 588 589 590 591 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 580 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
574 575 576 577 578 579 |
# File 'ext/fortio/lib/fortio/fortran_format.rb', line 574 def write (io, list, state) count.times do str = FortranFormat.write_G(state.sign, state.scale, length, prec, exp, list.shift) io << FortranFormat.check_length(length, str) end end |