[ruby] Creating a program that responds only to specific conditions

Contents

Write the code to display today's day of the week using the Date class. However, only if it is Friday, please change the displayed contents as follows.

(Output contents) "Today is Monday" "Today is Friday !!!"

Implementation

image.png image.png

Commentary

This time we will handle dates in Ruby, so we will use the Date class, which is a library. The first line calls the Date class from the library. You can use the wday method on the 3rd line to get today's value when it is an integer from 0 (Sunday) to 6 (Saturday).

Recommended Posts

[ruby] Creating a program that responds only to specific conditions
[Ruby] A program that determines prime numbers
A program that calculates factorials from 2 to 100
[Ruby] A program that uses search and each_with_index
[Ruby] A program / concept that combines each_with_index and search
Ruby Regular Expression Extracts from a specific string to a string
[IOS] To allow rotation of only a specific screen
[Ruby] I want to make a program that displays today's day of the week!
[Ruby On Rails] Description that allows only specific users to transition to the edit page
[Ruby] How to extract a specific value from an array under multiple conditions [select / each]
Creating a calendar using Ruby
To write a user-oriented program (1)
Apply CSS to a specific View in Ruby on Rails
[Ruby 3.0] A memo that I added a type definition to a library I wrote
Ruby: I made a FizzBuzz program!
[Ruby] Method to count specific characters
When you want Rails to disable a session for a specific controller only
A program that determines whether the entered integer is close to an integer
How to limit IP address only to a specific directory with laravel + nginx
How to create a validator that allows only input to any one field
The road to creating a music game 3
The road to creating a music game 1
Use Stream # collect to retrieve and list only specific fields from a JavaBean list
[Ruby on Rails] Try to create a service that makes local cats happy
A story about creating a library that operates next-generation sequencer data with Ruby ruby-htslib