Class: ODDB::Part

Inherits:
Object show all
Includes:
OddbYaml, Persistence, SizeParser
Defined in:
src/model/part.rb,
ext/export/src/oddb_yaml.rb

Constant Summary

EXPORT_PROPERTIES =
[
  '@measure', '@addition', '@commercial_form', '@composition',
]

Constants included from OddbYaml

EXPORT_PROPERTIES, YAML_URI

Constants included from SizeParser

UNIT

Constants included from Persistence

ODBA_PREDEFINE_SERIALIZABLE

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from OddbYaml

#to_yaml_properties, #to_yaml_type

Methods included from SizeParser

#_composition_scale, #active_agents, #comparable_size, #dose_from_measure, #dose_from_multi, #dose_from_scale, #multiplier, #parse_size, #set_comparable_size!, #size=

Methods included from Persistence

#initialize

Methods included from PersistenceMethods

#checkout, #data_origin, #data_origins, #diff, #nil_if_empty, #parent, #pointer_descr, #structural_ancestors, #undiffable?, #update_values

Constructor Details

This class inherits a constructor from ODDB::Persistence

Instance Attribute Details

- (Object) comform (readonly)

Returns the value of attribute comform



124
125
126
# File 'src/model/part.rb', line 124

def comform
  @comform
end

- (Object) commercial_form

Returns the value of attribute commercial_form



124
125
126
# File 'src/model/part.rb', line 124

def commercial_form
  @commercial_form
end

- (Object) composition

Returns the value of attribute composition



125
126
127
# File 'src/model/part.rb', line 125

def composition
  @composition
end

- (Object) package

Returns the value of attribute package



125
126
127
# File 'src/model/part.rb', line 125

def package
  @package
end

Class Method Details

+ (Object) package_delegate(*args)



106
107
108
109
110
111
112
# File 'src/model/part.rb', line 106

def package_delegate *args
  args.each { |name|
    define_method(name) { 
      @package.send(name) if @package
    }
  }
end

+ (Object) update_comparable_size(*args)



113
114
115
116
117
118
119
120
121
122
# File 'src/model/part.rb', line 113

def update_comparable_size *args
  args.each { |name|
    attr_reader name
    define_method("#{name}=") { |arg|
      instance_variable_set("@#{name}", arg)
      set_comparable_size!
      arg
    }
  }
end

Instance Method Details

- (Object) fix_pointers



140
141
142
143
# File 'src/model/part.rb', line 140

def fix_pointers
  @pointer = @package.pointer + [:part, @oid]
  odba_store
end

- (Object) init(app)



128
129
130
# File 'src/model/part.rb', line 128

def init(app)
  @pointer.append(@oid)
end

- (Object) size



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'src/model/part.rb', line 144

def size
  parts = []
  multi = @multi.to_i
  count = @count.to_i
  add = @addition.to_i
  if(multi > 1) 
    parts.push(multi)
  end
  @measure = nil if @measure == 1
  if(count > 0 && multi > 1 && !@measure)
    parts.push('x')
  end
  if add > 0
    parts.push add, '+'
  end
  if(count > 1 || (count > 0 && multi > 1 && !@measure))
    parts.push(count)
  end
  if(@commercial_form)
    parts.push @commercial_form
    parts.push "à" if @measure
  elsif @measure && !parts.empty?
    parts.push('x')
  end
  parts.push @measure if @measure
  parts.push('/', @scale) if @scale && @scale != 1
  parts.join(' ')
end

- (Object) to_yaml(opts = {})



391
392
393
394
395
396
397
398
399
400
401
# File 'ext/export/src/oddb_yaml.rb', line 391

def to_yaml( opts = {} )
  YAML::quick_emit( self.object_id, opts ) { |out|
    out.map( taguri ) { |map|
      map.add('count', self.count || 1)
      map.add('multi', self.multi || 1)
      to_yaml_properties.each { |m|
        map.add( m[1..-1], instance_variable_get( m ) )
      }
    }
  }
end