Module: Cul::Image::Properties::LittleEndian
- 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
257 258 259 260 261 262 263 |
# File 'lib/cul_image_props/image/properties/types.rb', line 257 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
271 272 273 274 275 276 277 |
# File 'lib/cul_image_props/image/properties/types.rb', line 271 def int(str, signed=false) result = str[0,4].unpack('V')[0] if signed return ~ result unless result < 2147483648 end return result end |
#short(str, signed = false) ⇒ Object
264 265 266 267 268 269 270 |
# File 'lib/cul_image_props/image/properties/types.rb', line 264 def short(str, signed=false) result = str[0,2].unpack('v')[0] if signed return ~ result unless result < 32768 end return result end |