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