Module: MITS::V3_0::Mapper::FilesMapper

Included in:
MITS::V3_0::Mapper, MITS::V4_1::Mapper
Defined in:
lib/mits/v3.0/mapper/files_mapper.rb

Instance Method Summary collapse

Instance Method Details

#file(tag, entity = File) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mits/v3.0/mapper/files_mapper.rb', line 10

def file(tag, entity = File)
  entity.new(active:      bool(tag[:Active]),
             caption:     tag[:Caption],
             description: tag[:Description],
             format:      tag[:Format],
             height:      try(tag[:Height], :to_i),
             id:          tag[:FileID],
             name:        tag[:Name],
             rank:        tag[:Rank],
             source:      tag[:Src],
             type:        tag[:FileType],
             width:       tag[:Width])
end

#files(tags, entity = File) ⇒ Object



5
6
7
8
# File 'lib/mits/v3.0/mapper/files_mapper.rb', line 5

def files(tags, entity = File)
  tags = [tags] unless tags.is_a? Array
  tags.map { |tag| file(tag, entity) }
end