Module: Utils::FileXt
- Extended by:
- DSLKit::Concern
- Includes:
- File::Constants
- Included in:
- File
- Defined in:
- lib/utils/file_xt.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
Instance Method Summary collapse
Instance Method Details
#ascii? ⇒ Boolean
29 30 31 32 33 34 |
# File 'lib/utils/file_xt.rb', line 29 def ascii? case binary? when true then false when false then true end end |
#binary? ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/utils/file_xt.rb', line 18 def binary? old_pos = tell seek 0, SEEK_SET data = read 2 ** 13 !data or data.empty? and return nil data.count(ZERO) > 0 and return true data.count(BINARY).to_f / data.size > 0.3 ensure seek old_pos, SEEK_SET end |