Module: Zenlish::Feature::FeatureStructDefBearer

Included in:
Lang, Lex::Lexeme, WClasses::WordClass
Defined in:
lib/zenlish/feature/feature_struct_def_bearer.rb

Overview

Mix-in module. It adds a feature structure defintion to its host and also factory methods to ease feature definition manipulation.

Instance Method Summary collapse

Instance Method Details

#[](aName) ⇒ Feature::FeatureDef, NilClass

Retrieve feature definition with given name.

Parameters:

  • aName (String)

    Name of feature def to search for.

Returns:



30
31
32
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 30

def [](aName)
  struct[aName]
end

#booleanFeature::BooleanDomain



35
36
37
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 35

def boolean
  BooleanDomain.instance
end

#enumeration(*items) ⇒ Feature::EnumerationDomain



40
41
42
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 40

def enumeration(*items)
  EnumerationDomain.new(*items)
end

#feature_def(aPair) ⇒ Object

Parameters:

  • aPair (Hash)

    hash with one pair { String => FeatureDomain }



49
50
51
52
53
54
55
56
57
58
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 49

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) ⇒ Object



60
61
62
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 60

def feature_def_dsl(&aBlock)
  instance_eval(&aBlock)
end

#identifier(aDefaultValue = nil) ⇒ Object



44
45
46
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 44

def identifier(aDefaultValue = nil)
  IdentifierDomain.instance
end

#init_struct_def(aParentStruct, aFeatureHash) ⇒ Object

Parameters:

  • aParentStruct (Feature::FeatureStructDef)

    parent structure

  • aFeatureHash (Hash)

    hash with pairs of the form: String => FeatureDomain



15
16
17
18
19
20
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 15

def init_struct_def(aParentStruct, aFeatureHash)
  @struct = FeatureStructDef.new(aParentStruct)
  aFeatureHash.each_pair do |name, domain|
    feature_def(name => domain)
  end
end

#structFeature::FeatureStructDef



23
24
25
# File 'lib/zenlish/feature/feature_struct_def_bearer.rb', line 23

def struct
  @struct
end