Module: SugarHigh::FileExt
- Included in:
- File
- Defined in:
- lib/sugar-high/file_ext.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#blank? ⇒ Boolean
instance methods.
- #has_content?(content_matcher = nil, &block) ⇒ Boolean
- #read_content(options = {}, &block) ⇒ Object (also: #with_content)
Instance Method Details
#blank? ⇒ Boolean
instance methods
47 48 49 |
# File 'lib/sugar-high/file_ext.rb', line 47 def blank? File.zero?(self.path) end |
#has_content?(content_matcher = nil, &block) ⇒ Boolean
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/sugar-high/file_ext.rb', line 51 def has_content? content_matcher = nil, &block content_matcher ||= yield begin content_matcher = content_matcher.to_regexp rescue raise ArgumentError, "Content match must be specified as either a String or Regexp" end matched = self.read_content =~ content_matcher !(matched).nil? end |