Class: TagBuilder::ContainerTagBwCd
- Inherits:
-
Object
- Object
- TagBuilder::ContainerTagBwCd
- Includes:
- Enumerable
- Defined in:
- lib/tag_builder/container_tag_bw_cd.rb
Overview
Container for tags between canonical documents
Instance Attribute Summary collapse
-
#tag_cd_rs_ref ⇒ Object
readonly
Returns the value of attribute tag_cd_rs_ref.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(revision, cd_start, cd_end) ⇒ ContainerTagBwCd
constructor
A new instance of ContainerTagBwCd.
- #tags_orderados ⇒ Object
Constructor Details
#initialize(revision, cd_start, cd_end) ⇒ ContainerTagBwCd
Returns a new instance of ContainerTagBwCd
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tag_builder/container_tag_bw_cd.rb', line 35 def initialize(revision,cd_start, cd_end) @review = revision @cd_start = cd_start @cd_end = cd_end # Tags ya elegidos @tag_cd_rs_ref=::TagBwCd.(revision,cd_start, cd_end).to_hash_groups(:tag_id) # Ahora, los tags por defecto que falta por elegir @predeterminados=[] @review.t_clases_documentos.each do |clase| clase..each do |tag| @predeterminados.push(tag.id) unless @tag_cd_rs_ref.keys.include? tag.id @tag_cd_rs_ref[tag.id]=[{:systematic_review_id=>revision.id, :cd_start=>cd_start.id, cd_end=>cd_end.id, :tag_id=>tag.id,:text=>tag.text,:user_id=>0,:decision=>nil}] end end end end |
Instance Attribute Details
#tag_cd_rs_ref ⇒ Object (readonly)
Returns the value of attribute tag_cd_rs_ref
34 35 36 |
# File 'lib/tag_builder/container_tag_bw_cd.rb', line 34 def tag_cd_rs_ref @tag_cd_rs_ref end |
Instance Method Details
#each ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/tag_builder/container_tag_bw_cd.rb', line 69 def each .each do |v| recs=::TagBuilder::TagBwCd.new(v[1]) recs.predeterminado=@predeterminados.include? v[0] yield recs end end |
#tags_orderados ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tag_builder/container_tag_bw_cd.rb', line 55 def @tag_cd_rs_ref.sort {|a,b| tag_1=a[1][0] tag_2=b[1][0] if @predeterminados.include? tag_1[:tag_id] and !@predeterminados.include? tag_2[:tag_id] +1 elsif !@predeterminados.include? tag_1[:tag_id] and @predeterminados.include? tag_2[:tag_id] -1 else tag_1[:text]<=>tag_2[:text] end } end |