Module: Exfuz::Util

Included in:
BookName, Cell, SheetName
Defined in:
lib/exfuz/util.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.wsl?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/exfuz/util.rb', line 14

def wsl?
  Etc.uname[:release].match?(/.*microsoft.*/)
end

.wsl_to_windows(path) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
# File 'lib/exfuz/util.rb', line 18

def wsl_to_windows(path)
  nil unless wsl?

  raise ArgumentError, 'not exists path' unless File.exist?(path)

  `wslpath -w #{path}`.chomp
end

Instance Method Details

#match?(word) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
# File 'lib/exfuz/util.rb', line 7

def match?(word)
  regexp = Regexp.new(word.downcase, Regexp::IGNORECASE)
  @text.match?(regexp)
end