<commit_before># PYR
[![Code Climate](https://codeclimate.com/github/msimonborg/pyr/badges/gpa.svg)](https://codeclimate.com/github/msimonborg/pyr)

PYR makes integrating data from the Phone Your Rep API into your Ruby project as easy as pie.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'pyr'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install pyr

## Usage

### Querying by location
```ruby
response = PYR.call :reps do |r|
  r.lat  = 44.5588028
  r.long = -72.57784149999999
end

## or ##

response = PYR.call(:reps) do { |r| r.address = 'Vermont' }

response.uri
=> "https://phone-your-rep.herokuapp.com/api/beta/reps?lat=44.5588028&long=-72.57784149999999&"

response.code
=> 200

response.message
=> "OK"

response.headers
=> { ... }

response.body
=> { ... }

reps = response.objects
=> #<PYR::RepRelation [#<PYR::Rep id: 1, ...>]>

reps.first.official_full
=> "<NAME>"

reps.first.office_locations_count
=> 3

reps.first.office_locations.first.city
=> "St. Johnsbury"
```

### Query the full index and narrowing with scopes
```ruby
response = PYR.call :reps

reps = response.objects

reps.count
=> 536

reps.democratic.count
=> 243

reps.senators.count
=> 100<commit_msg>small change to readme<commit_after># PYR
[![Code Climate](https://codeclimate.com/github/msimonborg/pyr/badges/gpa.svg)](https://codeclimate.com/github/msimonborg/pyr)

PYR makes integrating data from the Phone Your Rep API into your Ruby project as easy as pie.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'pyr'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install pyr

## Usage

### Querying by location
```ruby
response = PYR.call :reps do |r|
  r.lat  = 44.5588028
  r.long = -72.57784149999999
end

## or ##

response = PYR.call(:reps) do { |r| r.address = 'Vermont' }

response.uri
=> "https://phone-your-rep.herokuapp.com/api/beta/reps?lat=44.5588028&long=-72.57784149999999&"

response.code
=> 200

response.message
=> "OK"

response.headers
=> { ... }

response.body
=> { ... }

reps = response.objects
=> #<PYR::RepRelation [#<PYR::Rep id: 1, ...>]>

reps.first.official_full
=> "<NAME>"

reps.first.office_locations_count
=> 3

reps.first.office_locations.first.phone
=> "802-748-9269"
```

### Querying the full index and narrowing with scopes
```ruby
response = PYR.call :reps

reps = response.objects

reps.count
=> 536

reps.democratic.count
=> 243

reps.senators.count
=> 100
{'fraction_non_alphanumeric': 0.1589271417133707, 'fraction_numerical': 0.055244195356285025, 'mean_word_length': 3.9192913385826773, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 33, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3449844', 'n_tokens_mistral': 1083, 'n_tokens_neox': 926, 'n_words': 217}