Class: String
Overview
require_relative ‘../constraints’
Direct Known Subclasses
Instance Method Summary collapse
-
#flush ⇒ String
Left-flush a string based off of the number of whitespace characters on the first line.
-
#satisfied_by?(version) ⇒ Boolean
Treat strings as version constraints.
-
#satisfies?(*constraints) ⇒ Boolean
Treat strings as version objects.
Instance Method Details
#flush ⇒ String
Left-flush a string based off of the number of whitespace characters on the first line. This is especially useful for heredocs when whitespace matters.
63 64 65 |
# File 'lib/chef/sugar/core_extensions/string.rb', line 63 def flush gsub(/^#{self[/\A\s*/]}/, '').chomp end |
#satisfied_by?(version) ⇒ Boolean
Treat strings as version constraints.
46 47 48 |
# File 'lib/chef/sugar/core_extensions/string.rb', line 46 def satisfied_by?(version) Chef::Sugar::Constraints::Constraint.new(dup).satisfied_by?(version) end |
#satisfies?(*constraints) ⇒ Boolean
Treat strings as version objects.
31 32 33 |
# File 'lib/chef/sugar/core_extensions/string.rb', line 31 def satisfies?(*constraints) Chef::Sugar::Constraints::Version.new(dup).satisfies?(*constraints) end |