module Zenlish::Feature::FeatureStructDefBearer
Mix-in module. It adds a feature structure defintion to its host and also factory methods to ease feature definition manipulation.
Public Instance Methods
[](aName)
click to toggle source
Retrieve feature definition with given name. @param aName [String] Name of feature def to search for. @return [Feature::FeatureDef, NilClass]
# File lib/zenlish/feature/feature_struct_def_bearer.rb, line 32 def [](aName) struct[aName] end
boolean()
click to toggle source
@return [Feature::BooleanDomain]
# File lib/zenlish/feature/feature_struct_def_bearer.rb, line 37 def boolean BooleanDomain.instance end
enumeration(*items)
click to toggle source
@return [Feature::EnumerationDomain]
# File lib/zenlish/feature/feature_struct_def_bearer.rb, line 42 def enumeration(*items) EnumerationDomain.new(*items) end
feature_def(aPair)
click to toggle source
@param aPair [Hash] hash with one pair { String => FeatureDomain
}
# File lib/zenlish/feature/feature_struct_def_bearer.rb, line 51 def feature_def(aPair) if aPair.values[0].is_a?(Array) dom, val = aPair.values[0] val = dom.build_value(val) unless val.kind_of?(FeatureValue) featr_def = FeatureDef.new(aPair.keys[0], dom, val) else featr_def = FeatureDef.new(aPair.keys[0], aPair.values[0]) end @struct.add_feature_def(featr_def) end
feature_def_dsl(&aBlock)
click to toggle source
# File lib/zenlish/feature/feature_struct_def_bearer.rb, line 62 def feature_def_dsl(&aBlock) instance_eval(&aBlock) end
identifier(_default_value = nil)
click to toggle source
# File lib/zenlish/feature/feature_struct_def_bearer.rb, line 46 def identifier(_default_value = nil) IdentifierDomain.instance end
init_struct_def(aParentStruct, aFeatureHash)
click to toggle source
@param aParentStruct [Feature::FeatureStructDef] parent structure @param aFeatureHash [Hash] hash with pairs of the form: String => FeatureDomain
# File lib/zenlish/feature/feature_struct_def_bearer.rb, line 17 def init_struct_def(aParentStruct, aFeatureHash) @struct = FeatureStructDef.new(aParentStruct) aFeatureHash.each_pair do |name, domain| feature_def(name => domain) end end
struct()
click to toggle source
@return [Feature::FeatureStructDef]
# File lib/zenlish/feature/feature_struct_def_bearer.rb, line 25 def struct @struct end