Module: FRBR::Expression

Includes:
Group1, Group3
Defined in:
lib/frbr/expression.rb

Instance Attribute Summary collapse

Attributes included from Group3

#related_subjects, #subject_of

Attributes included from Group1

#relationships

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Group3

#add_related_subject, #add_subject_of, check_frbr_validity, #remove_related_subject, #remove_subject_of

Methods included from Group1

check_frbr_validity, #related

Instance Attribute Details

#embodimentsObject (readonly) Also known as: manifestations

Returns the value of attribute embodiments.



5
6
7
# File 'lib/frbr/expression.rb', line 5

def embodiments
  @embodiments
end

#realization_ofObject (readonly) Also known as: work

Returns the value of attribute realization_of.



5
6
7
# File 'lib/frbr/expression.rb', line 5

def realization_of
  @realization_of
end

#realizersObject (readonly)

Returns the value of attribute realizers.



5
6
7
# File 'lib/frbr/expression.rb', line 5

def realizers
  @realizers
end

Class Method Details

.valid_relationshipsObject



83
84
85
# File 'lib/frbr/expression.rb', line 83

def self.valid_relationships
  {:translation=>:translation_of, :revision=>:revision_of, :arrangement=>:arrangement_of, :derivative=>:based_on, :preceded_by=>:succeeded_by, :described_in=>:describes, :augmentation=>:augmentation_of, :contains=>:contained_in, :complemented_by=>:complements, :adaptation=>:adaptation_of, :imitation=>:imitation_of, :related=>:related}      
end

Instance Method Details

#add_embodiment(manifestation) ⇒ Object Also known as: add_manifestation

Raises:

  • (ArgumentError)


46
47
48
49
50
51
# File 'lib/frbr/expression.rb', line 46

def add_embodiment(manifestation)
  raise ArgumentError, "Embodiments must be manifestations" unless manifestation.is_a?(FRBR::Manifestation)
  @embodiments ||= []
  @embodiments << manifestation unless @embodiments.index(manifestation)
  manifestation.is_embodiment_of(self)
end

#add_realizer(realizer) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
33
34
# File 'lib/frbr/expression.rb', line 29

def add_realizer(realizer)
  raise ArgumentError, "Realizer must be a Group 2 entity" unless realizer.is_a?(FRBR::Group2)
  @realizers ||= []
  @realizers << realizer unless @realizers.index(realizer)
  realizer.add_realization(self) unless realizer.realizer_of?(self)
end


62
63
64
65
# File 'lib/frbr/expression.rb', line 62

def add_related(expression)
  (action, relationship) = this_method.split("_")
  self.add_relationship_to_entity(expression, relationship.to_sym, FRBR::Expression, true)
end

#clear_realization_ofObject Also known as: clear_expression_of



18
19
20
21
22
23
24
25
# File 'lib/frbr/expression.rb', line 18

def clear_realization_of
  if @realization_of && !@realization_of.nil? 
    if @realization_of.realizations && @realization_of.realizations.index(self)
      @realization_of.remove_realization(self) 
    end
    @realization_of = nil
  end
end

#equivalentsObject



72
73
74
75
76
77
78
79
80
81
# File 'lib/frbr/expression.rb', line 72

def equivalents
  equivalents = []
  if self.realization_of
    self.realization_of.realizations.each do | expression |
      next if expression == self
      equivalents << expression
    end
  end
  equivalents
end

#has_realizer?(agent) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
# File 'lib/frbr/expression.rb', line 41

def has_realizer?(agent)
  return true if @realizers && @realizers.index(agent)
  return false
end

#is_realization_of(work) ⇒ Object Also known as: is_expression_of

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/frbr/expression.rb', line 10

def is_realization_of(work)
  raise ArgumentError, "Must be a realization of a work" unless work.is_a?(FRBR::Work)
  @realization_of = work
  work.add_realization(self) unless work.realizations && work.realizations.index(self)
end

#remove_embodiment(manifestation) ⇒ Object Also known as: remove_manifestation



55
56
57
58
# File 'lib/frbr/expression.rb', line 55

def remove_embodiment(manifestation)
  @embodiments.delete(manifestation) if @embodiments
  manifestation.clear_embodiment_of
end

#remove_realizer(realizer) ⇒ Object



36
37
38
39
# File 'lib/frbr/expression.rb', line 36

def remove_realizer(realizer)
  @realizers.delete(realizer)
  realizer.remove_realization(self) if realizer.realizer_of?(self)
end


67
68
69
70
# File 'lib/frbr/expression.rb', line 67

def remove_related(expression)
  (action, relationship) = this_method.split("_")
  self.remove_relationship_from_entity(expression, relationship.to_sym, FRBR::Expression, true)
end