Giter Site home page Giter Site logo

meteorologist's Introduction

METEOROLOGIST

Installation

simply gem install 'meteorologist' or, in your Gemfile:

gem 'meteorologist'

and then require 'meteorologist' where necessary

Set up

You MUST provide the following environment variables:

DARKSKYSECRET - secret key for your Darksky API account
GOOGLEMAPSECRET - secret key for your Google Maps API account

You can optionally set a cache path - this will be used to cache searched location coordinates and limit calls made to the Google Maps API:

CACHE_PATH - path to YAML file used for location cache

Use

options = {
  units: 'si', # default
  forecast_time: Time.new(2016, 2, 23) # defaults to Time.now
}
weatherman = Meteorologist.new("berlin")

weatherman.location_name
=> "Berlin, Germany"

weatherman.forecast.methods
=> [:current_summary, :current_temperature, :current_apparent_temperature,
:current_humidity, :todays_summary, :sunrise, :sunset, :moon_phase,
:minimum_temperature, :apparent_minimum_temperature, :maximum_temperature,
:apparent_maximum_temperature]

weatherman.moon.methods
=> [:illumination, :waxing?, :waning?, :phase_name, :emoji, :active_elements]

Options

The units option defaults to 'si', which is metric units. For the full list of other available units, please see the Darksky documentation

The forecast_time option can be used to get historical forecast data. It defaults to Time.now.

Methods

Most of the forecast methods are self-explanatory.

Both sunrise and sunset take into account the time offset given by Darksky for the forecasted location, so they should be adjusted to local time.

The moon_phase returns Darksky's phase estimation which does what it says on the tin, but is not terribly helpful. It's literally the percent of the cycle complete - so 0% is the new moon, 50% is the full moon and 100% is the next new moon.

The moon method returns some helpers related to moon information:

  • illumination - percent of the moon which is illuminated
  • waxing?/waning? - boolean if the moon is waxing or waning
  • phase_name - string value of the moon's current phase (new, crescent, first quarter, etc)
  • emoji - emoji of the current moon phase ^_^
  • active_elements - array of astrological elements related to the current moon phase. In the case of two elements, a transition is being made from the first element to the last.

meteorologist's People

Contributors

daxadax avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.