Class: FortIO::Namelist::Parser::ParamDef
- Inherits:
-
Struct
- Object
- Struct
- FortIO::Namelist::Parser::ParamDef
- Defined in:
- lib/fortio-namelist/fortran_namelist.rb,
lib/fortio-namelist/fortran_namelist.rb
Instance Attribute Summary collapse
-
#array_spec ⇒ Object
Returns the value of attribute array_spec.
-
#ident ⇒ Object
Returns the value of attribute ident.
-
#rval ⇒ Object
Returns the value of attribute rval.
Instance Method Summary collapse
Instance Attribute Details
#array_spec ⇒ Object
Returns the value of attribute array_spec
17 18 19 |
# File 'lib/fortio-namelist/fortran_namelist.rb', line 17 def array_spec @array_spec end |
#ident ⇒ Object
Returns the value of attribute ident
17 18 19 |
# File 'lib/fortio-namelist/fortran_namelist.rb', line 17 def ident @ident end |
#rval ⇒ Object
Returns the value of attribute rval
17 18 19 |
# File 'lib/fortio-namelist/fortran_namelist.rb', line 17 def rval @rval end |
Instance Method Details
#inspect ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/fortio-namelist/fortran_namelist.rb', line 58 def inspect if array_spec return "#{ident}(#{array_spec.inspect}) = #{rval.inspect}" else return "#{ident} = #{rval}" end end |
#set(hash) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fortio-namelist/fortran_namelist.rb', line 21 def set (hash) case hash[ident] when Array case array_spec when nil if rval.is_a?(Array) and rval.size == 1 hash[ident][0] = rval.first else hash[ident].clear hash[ident].push(*rval) end else if array_spec.first.is_a?(Integer) if rval.size == 1 hash[ident][*array_spec] = rval.first else idx = array_spec.first hash[ident][idx..idx+rval.size-1] = *rval end else hash[ident][*array_spec] = rval end end else if array_spec hash[ident] = [] set(hash) else if rval.is_a?(Array) and rval.size == 1 hash[ident] = rval.first else hash[ident] = rval end end end end |