Module: Cul::Image::Properties::BigEndian
- Defined in:
- lib/cul_image_props/image/properties/types.rb
Instance Method Summary collapse
- #byte(str, signed = false) ⇒ Object
- #int(str, signed = false) ⇒ Object
- #short(str, signed = false) ⇒ Object
Instance Method Details
#byte(str, signed = false) ⇒ Object
285 286 287 288 289 290 291 |
# File 'lib/cul_image_props/image/properties/types.rb', line 285 def byte(str, signed=false) if signed return str[0,1].unpack('c')[0] else return str[0,1].unpack('C')[0] end end |
#int(str, signed = false) ⇒ Object
299 300 301 302 303 304 305 |
# File 'lib/cul_image_props/image/properties/types.rb', line 299 def int(str, signed=false) result = str[0,4].unpack('N')[0] if signed return ~ result unless result < 2147483648 end return result end |
#short(str, signed = false) ⇒ Object
292 293 294 295 296 297 298 |
# File 'lib/cul_image_props/image/properties/types.rb', line 292 def short(str, signed=false) result = str[0,2].unpack('n')[0] if signed return ~ result unless result < 32768 end return result end |