Class: NetCDF::AttributeWriter

Inherits:
Attribute show all
Defined in:
lib/netcdf/attribute.rb

Overview

Instance Attribute Summary

Attributes inherited from CDMNode

#netcdf_elmt

Class Method Summary collapse

Methods inherited from Attribute

#array?, #data_type, #length, #numeric_value, #string?, #string_value, #to_string, #unsigned?, #value, #write_cdl

Methods inherited from CDMNode

#get_full_name, #get_short_name, #initialize

Constructor Details

This class inherits a constructor from NetCDF::CDMNode

Class Method Details

.build(name, val, type = "int") ⇒ Object





129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/netcdf/attribute.rb', line 129

def self.build(name, val, type = "int")

  type = type.to_sym
  value = val
  if (val.is_a? Numeric)
    value = val.to_java(type)
  elsif (val.is_a? Array)
    value = Array.new
    val.each do |elmt|
      if (elmt.is_a? Numeric)
        value << elmt.to_java(type)
      else
        value << elmt
      end
    end
  end

  NetCDF::Attribute.new(Java::UcarNc2::Attribute.new(name, value))

end