Sha256: 1113afba69bff1e2be5483b5542ac5aba039edd61a9e11a8939efd5edc64369b
Contents?: true
Size: 734 Bytes
Versions: 1
Compression:
Stored size: 734 Bytes
Contents
require 'xml/mapping' require 'stash/wrapper/size_unit' module Stash module Wrapper # Mapping for `<st:size>` class Size include ::XML::Mapping numeric_node :size, '.' typesafe_enum_node :unit, '@unit', class: SizeUnit, default: SizeUnit::BYTE # Creates a new {Size} # @param bytes [Integer] the size in bytes def initialize(bytes:) self.size = valid_size(bytes) self.unit = SizeUnit::BYTE end private def valid_size(bytes) return bytes if bytes && bytes.respond_to?(:to_i) && bytes == bytes.to_i raise ArgumentError, "specified file size does not appear to be an integer byte count: #{bytes || 'nil'}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stash-wrapper-0.1.12 | lib/stash/wrapper/size.rb |