Module: Kernel
- Defined in:
- lib/asautotest/utilities.rb
Overview
You should have received a copy of the GNU General Public License along with ASAutotest. If not, see <www.gnu.org/licenses/>.
Instance Method Summary collapse
- #build_string(&block) ⇒ Object
- #gather(&block) ⇒ Object
- #ljust(string, width) ⇒ Object
- #padding(string, width) ⇒ Object
- #returning(value) {|value| ... } ⇒ Object
- #rjust(string, width) ⇒ Object
- #string_width(string) ⇒ Object
Instance Method Details
#build_string(&block) ⇒ Object
29 30 31 |
# File 'lib/asautotest/utilities.rb', line 29 def build_string(&block) returning("", &block) end |
#gather(&block) ⇒ Object
25 26 27 |
# File 'lib/asautotest/utilities.rb', line 25 def gather(&block) returning([], &block) end |
#ljust(string, width) ⇒ Object
33 34 35 |
# File 'lib/asautotest/utilities.rb', line 33 def ljust(string, width) string + padding(string, width) end |
#padding(string, width) ⇒ Object
41 42 43 |
# File 'lib/asautotest/utilities.rb', line 41 def padding(string, width) " " * [0, width - string_width(string)].max end |
#returning(value) {|value| ... } ⇒ Object
21 22 23 |
# File 'lib/asautotest/utilities.rb', line 21 def returning(value) yield value ; value end |
#rjust(string, width) ⇒ Object
37 38 39 |
# File 'lib/asautotest/utilities.rb', line 37 def rjust(string, width) padding(string, width) + string end |
#string_width(string) ⇒ Object
45 46 47 |
# File 'lib/asautotest/utilities.rb', line 45 def string_width(string) string.gsub(/\e.*?m/, "").size end |