Skip to main content Link Search Menu Expand Document (external link)

StringItem

MethodParametersDescriptionExample
truthy? Item state not UNDEF, not NULL and is not blank (‘’) when trimmed.puts "#{item.name} is truthy" if item.truthy?
String methods* All methods for Ruby StringStringOne << StringOne + ' World!'
blank? True if state is UNDEF, NULL, string is empty or contains only whitespaceStringOne << StringTwo unless StringTwo.blank?
  • All String methods returns a copy of the current state as a string. Methods that modify a string in place, do not modify the underlying state string.

Examples

String operations can be performed directly on the StringItem

# StringOne has a current state of "Hello"
StringOne << StringOne + " World!"
# StringOne will eventually have a state of 'Hello World!'

# Add Number item to 5
NumberOne << 5 + NumberOne

String Items can be selected in an enumerable with grep.

# Get all StringItems
items.grep(StringItem)
     .each { |string| logger.info("#{string.id} is a String Item") }

String Item values can be matched against regular expressions

# Get all Strings that start with an H
Strings.grep(/^H/)
        .each { |string| logger.info("#{string.id} starts with an H") }