Class: ContentTypes
- Inherits:
-
Object
- Object
- ContentTypes
- Defined in:
- lib/ruby3mf/content_types.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #get_type(target) ⇒ Object
- #get_types ⇒ Object
-
#initialize(found = {}, over = {}) ⇒ ContentTypes
constructor
A new instance of ContentTypes.
- #size ⇒ Object
Constructor Details
#initialize(found = {}, over = {}) ⇒ ContentTypes
Returns a new instance of ContentTypes.
3 4 5 6 |
# File 'lib/ruby3mf/content_types.rb', line 3 def initialize(found={}, over={}) @found_types=found @found_overrides=over end |
Instance Method Details
#empty? ⇒ Boolean
12 13 14 |
# File 'lib/ruby3mf/content_types.rb', line 12 def empty? size == 0 end |
#get_type(target) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby3mf/content_types.rb', line 16 def get_type(target) target = (target.start_with?('/') ? target : '/' + target).downcase if @found_overrides[target] content_type = @found_overrides[target] else extension = File.extname(target).strip.downcase[1..-1] content_type = @found_types[extension] end content_type end |
#get_types ⇒ Object
27 28 29 |
# File 'lib/ruby3mf/content_types.rb', line 27 def get_types() return @found_types.values + @found_overrides.values end |
#size ⇒ Object
8 9 10 |
# File 'lib/ruby3mf/content_types.rb', line 8 def size @found_types.size + @found_overrides.size end |