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
281 282 283 284 285 286 287 |
# File 'lib/cul_image_props/image/properties/types.rb', line 281 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
295 296 297 298 299 300 301 |
# File 'lib/cul_image_props/image/properties/types.rb', line 295 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
288 289 290 291 292 293 294 |
# File 'lib/cul_image_props/image/properties/types.rb', line 288 def short(str, signed=false) result = str[0,2].unpack('n')[0] if signed return ~ result unless result < 32768 end return result end |