Class: BatteryType

Inherits:
Object show all
Extended by:
DefaultAssertions::ClassMethods, NoDB::ClassMethods
Includes:
Assertions, Examples, DefaultAssertions, NoDB
Defined in:
app/models/battery_type.rb

Defined Under Namespace

Modules: Assertions, Examples

Constant Summary collapse

MAX_CONFIRMATIONS =

form_factors

10

Constants included from ColumnGroup::ClassMethods

ColumnGroup::ClassMethods::History_columns

Constants included from GenericGrep::ClassMethods

GenericGrep::ClassMethods::ASSOCIATION_MACRO_LETTERS, GenericGrep::ClassMethods::ASSOCIATION_MACRO_PATTERN

Constants included from NoDB

NoDB::DEFAULT_TYPE

Constants included from GenericTableAssociation::Examples

GenericTableAssociation::Examples::First_stream_method

Instance Attribute Summary

Attributes included from NoDB

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NoDB::ClassMethods

column_symbols, data_source_yaml, default_names, dump, get_field_names, insert_sql, table_class, table_name

Methods included from Generic_Table::ClassMethods

#is_active_record_method?, #model_file_name, #nesting, #one_pass_statistics, #sample, #sample_burst

Methods included from ColumnGroup::ClassMethods

#attribute_ddl, #attribute_rails_type, #attribute_ruby_type, #candidate_logical_keys_from_indexes, #categorical?, #column_symbols, #default_logical_primary_key, #defaulted_primary_logical_key?, #history_type?, #is_logical_primary_key?, #logical_attributes, #logical_primary_key, #logical_primary_key_recursive, #numerical?, #probably_categorical?, #probably_numerical?, #sequential_id?

Methods included from GenericGrep::ClassMethods

#all_associations, #association_grep, #association_grep_pattern, #association_macro_type, #association_type, #belongs_to_association?, #grep_all_associations_command, #grep_command, #has_many_association?, #has_one_association?, #model_grep, #model_grep_command

Methods included from GenericTableHtml::ClassMethods

#column_order, #header_html, #table_html

Methods included from NoDB

#[], #[]=, #clone, #each_pair, #has_key?, #initialize, #insert_sql, #keys, #table_class, #table_name

Methods included from Generic_Table

activeRecordTableNotCreatedYet?, classDefiniton, classReference, class_of_name, eval_constant, is_ActiveRecord_table?, is_generic_table?, is_generic_table_name?, is_table?, rails_MVC_class?, rubyClassName, table_exists?

Methods included from GenericTableAssociation

#associated_foreign_key_records, #associated_to_s, #association_class, #association_has_data, #association_state, #foreign_key_points_to_me?, #foreign_key_to_association, #foreign_key_value, #logical_primary_key_recursive_value, #logical_primary_key_value, #name_to_association

Methods included from GenericTableAssociation::Assertions::ClassMethods

#assert_foreign_keys_not_nil, #assert_invariant, #assert_post_conditions, #assert_pre_conditions

Methods included from GenericTableAssociation::Assertions

#assert_associated_foreign_key, #assert_associated_foreign_key_name, #assert_association, #assert_association_methods, #assert_association_to_many, #assert_association_to_one, #assert_foreign_key_association_names, #assert_foreign_key_name, #assert_foreign_key_not_nil, #assert_foreign_keys_not_nil, #assert_invariant, #assert_post_conditions, #assert_pre_conditions

Methods included from GenericTableHtml

#column_html, #rails_route, #row_html

Class Method Details

.allObject

standardize_keys!


32
33
34
35
36
# File 'app/models/battery_type.rb', line 32

def self.all
	data_source_yaml('battery_types').values.map do |r| #map
		BatteryType.new(r).standardize_keys?	
	end #map
end

.brandsObject

chemistries


40
41
42
# File 'app/models/battery_type.rb', line 40

def self.brands
	all.map {|r| r[:Brand]}.uniq
end

.chemistriesObject

all


37
38
39
# File 'app/models/battery_type.rb', line 37

def self.chemistries
	all.map {|r| r[:Chemistry]}.uniq
end

.column_remapObject

logical_primary_key


56
57
# File 'app/models/battery_type.rb', line 56

def self.column_remap
end

.form_factorsObject

brands


43
44
45
# File 'app/models/battery_type.rb', line 43

def self.form_factors
	all.map {|r| r[:Size]}.uniq
end

.logical_primary_keyObject


47
48
49
50
51
52
53
54
55
# File 'app/models/battery_type.rb', line 47

def self.logical_primary_key
	matches=Array.new()
	data_source_yaml('battery_types').each_pair do |composite_key, record|
		matches=matches&composite_key.split(',').map do |key|
			record.split(',').map {|field| feild==key}
		end #map
		
	end # each_pair
end

Instance Method Details

#standardize_keys?Boolean

to_lowercase_symbols

Returns:

  • (Boolean)

24
25
26
27
28
29
30
31
# File 'app/models/battery_type.rb', line 24

def standardize_keys?
	ret={}
	each_pair do |key, value|
		name=key[0].upcase + key[1..-1] # upper case first letter (like constant)
		ret[name.to_sym] =value
	end #each_pair
	BatteryType.new(ret)
end